Database Reference
In-Depth Information
will not only open but open to Pot Roast. While we are solving the Spotlight
issue, we are also going to take a look at Quick Look. Although on the surface
these two technologies appear to be completely different, they are handled in
a very similar fashion by Mac OS X and the Finder. And although it is not
100 percent appropriate for our sample application (since we have only a
single data file and that data file is hidden away in the Library/Application
Support directory), it is very useful to understand how Quick Look works for
document-based Core Data applications because it makes them easier to find
in Finder, Spotlight, Time Machine, Mail, and many other applications.
Lastly, Quick Look and Spotlight integrate rather well together. If our users
activate Quick Look on a Spotlight result, we want them to see information
about the recipe, not a picture of a generic file.
Should I Just Use Separate Files?
Throughout this topic, the application we are designing uses a single Core Data file.
This is done for the sake of clarity and focus on Core Data. Depending on the appli-
cation that is being designed, it is highly likely that it will be document-based, and
therefore it would be appropriate to have one Core Data repository per document. In
that situation, Spotlight and Quick Look can be a lot easier to integrate.
However, for applications that are not document-based, it is preferable to use a single
Core Data repository, as opposed to individual files. Although individual files make
Spotlight easier to work with, they would be the tail wagging the dog. The main focus
of object persistence (in other words, data files) is to quickly and easily access the
data in a logical and reproducible manner. Core Data solves all those problems quite
neatly—with the unfortunate minor wrinkle of not being fully compatible with
Spotlight.
9.1
Integrating with Spotlight
The issue, as mentioned, is one of multiple files. Ideally, for our recipe appli-
cation, we want one Spotlight “record” for each recipe in our Core Data
repository. For Spotlight to work properly, we would need one file on the disk
for each recipe, along with its associated metadata. Therefore, to make Spot-
light happy, we will do exactly that. However, since all our data is being stored
in a Core Data repository, there is no reason to store any data in these files.
These additional files exist purely for Spotlight (and Quick Look) to utilize.
Since Spotlight does not need any data in the files to work (it just needs
metadata), we will create very simple files and link them back to our Core
Data repository.
 
 
 
Search WWH ::




Custom Search