限制 NSMetadataQuery 的范围
我试图限制 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,我认为这是不可能的,因为
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.
一种方法是在 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.