How do I get Spotlight attributes to display in the get info window?
Posted
by Alexander Rauchfuss
on Stack Overflow
See other posts from Stack Overflow
or by Alexander Rauchfuss
Published on 2010-05-15T18:59:37Z
Indexed on
2010/05/15
19:04 UTC
Read the original article
Hit count: 252
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;
}
© Stack Overflow or respective owner