Developing for Mac OS X is about functionality meeting quality. When our applications have one without the other, we leave our users wanting more. They may not be able to define it, but “something” will be missing. Spotlight and Quick Look integration are two of those things that users don’t look for when trying a new application but are pleasantly surprised by when they stumble upon them. Surprisingly, not a lot of developers handle this integration. Perhaps it’s because Spotlight doesn’t get along with Core Data very well. Perhaps the feature is too abstracted away. But one thing is for certain—integrating with Spotlight is the right move going forward. Spotlight is here to stay, and users will be using it more often and in more creative ways.
Unfortunately, for technical reasons, Spotlight and Core Data are at odds with each other. Spotlight works on the metadata of individual files, and Core Data stores everything in a single file. Because Spotlight is designed to work with the metadata of a file to discover things about the file, it won’t work very well with a single file design such as Core Data. When Tiger was first released, there were a number of applications (such as Entourage) that, because of their single file design, did not play nicely with Spotlight. In fact, Apple re-architected Mail for that reason.
In this chapter, we’ll integrate Spotlight into our recipes application. Once we’re done, our users will be able to search for Pot Roast and find it in our application. Also, when they select that search result, our application will not only launch but open to Pot Roast. While we’re solving the Spotlight issue, we’re also going to glance at Quick Look. On the surface these two technologies appear to be completely different, but they’re handled in a similar fashion by Mac OS X and the Finder. And although it’s 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’s 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 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.