Database Reference
In-Depth Information
In the -metadataFolder , we first request a list of the cache directories from the
NSSearchPathForDirectoriesInDomain method and append the path components
Metadata and GrokkingRecipes to it. We do not check to see whether the path exists
at this point but instead let our caller decide how to handle that.
Creating the Spotlight Importer
Now that we have some metadata to work with, it's time to build the Spotlight
importer. To start this part of the application, we need to first address UTI s.
Uniform Type Identifiers (UTIs)
Both Spotlight and Quick Look use UTI s rather than filename extensions to
connect files on disk with (Spotlight) importers and (Quick Look) generators.
A UTI is a unique string that identifies the type of data stored in a given file.
It is recommended that UTI s identify the company and application that created
the data file, and like bundle identifiers, a reverse domain name is ideal for
this purpose. (It should be noted that bundle identifiers are in fact UTI s
themselves.) Since our application uses com.pragprog.grokkingrecipes as its unique
bundle identifier, we will use the same UTI as the value of the LSItemContentTypes
to identify the files.
Spotlight/Info.plist
<key> CFBundleDocumentTypes </key>
<array>
<dict>
<key> CFBundleTypeExtensions </key>
<array>
<string> grokkingrecipe </string>
</array>
<key> CFBundleTypeIconFile </key>
<string> book.icns </string>
<key> CFBundleTypeName </key>
<string> Grokking Recipe </string>
<key> CFBundleTypeRole </key>
<string> Editor </string>
<key> LSItemContentTypes </key>
<array>
<string> com.pragprog.grokkingrecipe </string>
</array>
<key> NSPersistentStoreTypeKey </key>
<string> XML </string>
</dict>
</array>
The UTExportedTypeDeclarations section is probably very familiar. Xcode generates
it to describe any file that is handled by the application being built. The one
difference is that, instead of defining a file extension (like .txt ), we are defining
 
 
 
Search WWH ::




Custom Search