How do I get Spotlight attributes to display in the get info window?
- by Alexander Rauchfuss
I have created a spotlight importer for comic files. The attributes are successfully imported and searchable. The one thing that remains is getting the attributes to display in a file's get info window.
It seems that this should be a simple matter of editing the schema.xml file so the attributes are nested inside displayattrs tags. Unfortunately this does not seem to be working.
I simplified the plugin for testing. The following are all of the important files.
schema.xml
<types>
<type name="cx.c3.cbz-archive">
<allattrs>
kMDItemTitle
kMDItemAuthors
</allattrs>
<displayattrs>
kMDItemTitle
kMDItemAuthors
</displayattrs>
</type>
<type name="cx.c3.cbr-archive">
<allattrs>
kMDItemTitle
kMDItemAuthors
</allattrs>
<displayattrs>
kMDItemTitle
kMDItemAuthors
</displayattrs>
</type>
GetMetadataForFile.m
Boolean GetMetadataForFile(void* thisInterface,
CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFStringRef pathToFile)
{
NSAutoreleasePool * pool = [NSAutoreleasePool new];
NSString * file = (NSString *)pathToFile;
NSArray * authors = [[UKXattrMetadataStore stringForKey: @"com_opencomics_authors" atPath: file traverseLink: NO] componentsSeparatedByString: @","];
[(NSMutableDictionary *)attributes setObject: authors forKey: (id)kMDItemAuthors];
NSString * title = [UKXattrMetadataStore stringForKey: @"com_opencomics_title" atPath: file traverseLink: NO];
[(NSMutableDictionary *)attributes setObject: title forKey: (id)kMDItemTitle];
[pool release];
return true;
}