使用NSPredicateEditor,有没有办法免费获取所有Finder搜索类别? [英] Using NSPredicateEditor, is there a way to get all of the Finder search categories for free?

查看:105
本文介绍了使用NSPredicateEditor,有没有办法免费获取所有Finder搜索类别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向应用程序添加NSPredicateEditor,以允许用户搜索特定文件和文件类别。

I'm adding an NSPredicateEditor to my app to allow the user to seach for specific files and categories of files.

Inteface Builder的默认NSPredicateEditor模板会添加一个控件仅包含名称,地址和标志类别。我正在寻找更具体的类别。

The default NSPredicateEditor template from Inteface Builder adds a control containing only "name", "address", and "sign" categories. I'm looking for more specific categories.

我知道我可以在Interface Builder中将菜单项添加到这些菜单中,但是我不希望自己维护文件搜索的所有类别和值的列表。

I know that I can add menu items to these menus in Interface Builder, but I would greatly prefer not to maintain a list myself of all of the various categories and values for file searches.

在Finder中,可以将各种各样的类别和值添加到搜索中。

In Finder, a great variety of categories and values can be added to searches.

通过保存搜索,然后在保存的seach文件夹中使用获取信息,可以显示用于生成Finder的NSPredicateEditor的谓词:

Using saving this search then using "Get Info" on the saved seach folder reveals the predicate used to generate the Finder's NSPredicateEditor:

((** = "this*"cdw) &&
(kMDItemContentTypeTree = "public.png"cd) &&
InRange(kMDItemLastUsedDate,$time.today(-2d),$time.today(+1d)) &&
InRange(kMDItemContentModificationDate,$time.today(-4d),$time.today(+1d)) &&
InRange(kMDItemContentCreationDate,$time.today(-8d),$time.today(+1d)) &&
(kMDItemDisplayName = "*screenshot*"cd) && (kMDItemTextContent = "content*"cdw))

单击其他类别类型将弹出菜单甚至还有更多 more 特定类别。

Clicking the "Other" category type brings up a menu with a wide variety of even more specific categories.

我的问题是,是否将来自Finder的相同的复杂且自定义的NSPredicateEditor添加到免费到我的应用程序中?还是我需要声明然后维护我的应用支持的所有搜索类型的列表?

My question is if this same complicated and customized NSPredicateEditor from Finder be added "for free" to my app? Or will I need to declare and then maintain a list of all of the search types my app supports?

推荐答案

有点晚了,但是您应该查看MDSchema.h。 MDSchemaCopyAllAttributes将返回整个受支持的Spotlight模式,MDSchemaCopyDisplayNameForAttribute将返回列表的显示名称,MDSchemaCopyDisplayDescriptionForAttribute将返回模式中每个项目的值类型。由此您可以构建自己的NSRuleEditor。 NSPredicateEditor会更难,因为您会内置许多行为,因此必须重写,但仍然可能。

A little late, but you should look at MDSchema.h. MDSchemaCopyAllAttributes will return the entire supported Spotlight schema, MDSchemaCopyDisplayNameForAttribute will return the display name for the list, and MDSchemaCopyDisplayDescriptionForAttribute will return the value types for each item in the schema. From this you can build your own NSRuleEditor. NSPredicateEditor would be harder, since you are getting a lot of behavior built in that you then have to override, but probably still possible.

这篇关于使用NSPredicateEditor,有没有办法免费获取所有Finder搜索类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆