在 Cocoa 中使用 Spotlight

发布于 2024-09-24 04:56:53 字数 304 浏览 0 评论 0原文

我可以在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是偏爱你 2024-10-01 04:56:53

您可以使用 NSMetadataQuery 类或其底层 CFType MDQueryO'Reilly 发布了一个示例

You can use the NSMetadataQuery class or its underlying CFType MDQuery. O'Reilly has published an example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文