在 Cocoa 中使用 Spotlight
我可以在 Cocoa 中使用 Spotlight API(它们存在,对吗?)来确定 Spotlight(在右上角)是否将给定的 filePath 与给定的字符串匹配?
换句话说,给定一个文件路径(例如“/Users/enchilada/Desktop/MapOfUSA.pdf”)和一个字符串(例如“Virginia”),当输入“Virginia”时,我如何判断 Spotlight 是否会显示此文件右上角的 Spotlight 搜索? (正如您可以想象的,在所示的示例中,它可能会匹配,因为美国的 PDF 地图可能包含弗吉尼亚州。)
如果可能,我们将不胜感激。
Can I use the Spotlight APIs (they exist, right?) in Cocoa to determine if Spotlight (in the upper-right corner) would match a given filePath with a given string?
In other words, given a filePath such as "/Users/enchilada/Desktop/MapOfUSA.pdf", and a string such as "Virginia", how would I tell if Spotlight would show this file when "Virginia" would have been typed in the upper-right Spotlight search? (As you can imagine, in the example shown, it would probably be matched, because a PDF map of the USA probably contains Virgina.)
If possible, a simple code piece to do this would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
NSMetadataQuery
类或其底层 CFTypeMDQuery
。 O'Reilly 发布了一个示例 。You can use the
NSMetadataQuery
class or its underlying CFTypeMDQuery
. O'Reilly has published an example.