限制 NSMetadataQuery 的范围

发布于 2024-09-26 15:38:39 字数 383 浏览 1 评论 0原文

我试图限制 NSMetadataQuery 项目的范围。我知道有 -setSearchScope: 方法(请参阅 docs),但它只让我决定该项目将在哪些目录中搜索。

如果我需要从范围中排除一个或多个目录怎么办?

I was trying to restrict the scope of an NSMetadataQuery item. I know there's the -setSearchScope: method (see the docs), but it lets me only decide in which directories the item will search.

What if I need to exclude one or more directories from the scope?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

⊕婉儿 2024-10-03 15:38:39

不幸的是,我认为这是不可能的,因为 kMDItemPath 属性未由 Spotlight 索引,因此无法在查询中使用。

提交错误

Unfortunately, I don't believe this is possible, since the kMDItemPath attribute is not indexed by Spotlight, and is therefore not usable in a query.

File a bug.

中二柚 2024-10-03 15:38:39

一种方法是在 setSearchScope 数组中设置所有包含路径,忽略您不想要的内容。当然,只有提前了解这些信息才有好处。

One way would be to set all the include paths in the setSearchScope array, leaving out what you don't want. Of course that is only good if you know those ahead of time.

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