如何让 Spotlight 属性显示在获取信息窗口中?
我为漫画文件创建了一个聚光灯导入器。属性已成功导入并可搜索。剩下的一件事是让属性显示在文件的获取信息窗口中。
看起来这应该是编辑 schema.xml 文件的简单问题,以便属性嵌套在 displayattrs 标记内。不幸的是,这似乎不起作用。
我简化了测试插件。以下是所有重要文件。
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>
</types>
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;
}
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>
</types>
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎缺少
标签。编写问题时复制/粘贴错误,或者 XML 文件中也缺少该问题吗?
如果文件中缺少它,则 XML 无效。
You seem to be missing a
</types>
tag. Copy/paste error in writing the question, or is it missing in the XML file, too?If it's missing in the file, the XML is invalid.
您的插件文件夹结构是什么样的?
它应该是这样的(取自 QuartzComposer),以便 Spotlight 导入程序进程找到并处理 schema.xml:
What does your plugin folder structure look like?
It should be something like this (taken from QuartzComposer) in order for the schema.xml to be found and processed by the Spotlight importer process: