Using NSPredicateEditor, is there a way to get all Finder search categories for free?

I am adding NSPredicateEditor to my application to allow the user to find specific files and file categories.

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

default interface builder NSPredicateEditor

I know that I can add menu items to these menus in Interface Builder, but I really would not want the list of all categories and values ​​to search for files to be saved.

In Finder, you can add a large number of categories and values ​​to search.

default categories for finder search

Using the save of this search, then using the Get Info button, the predicate used to create the Finder NSPredicateEditor is displayed in the saved seach folder:

((** = "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)) 

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

Other Finder Search Categories

My question is, can I add this sophisticated and customizable NSPredicateEditor from Finder to my application? Or will I need to declare and then save a list of all the search types supported by my application?

0
source share
2 answers

My question is, will this complex and custom NSPredicateEditor from Finder be added β€œfor free” to my application?

No, this NSRuleEditor is part of the Finder application.

Yes, with a few extra ones. A similar editor is located in the "Open / Save File" panel.

+1
source

A bit 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 value types for each chart element. From this you can create your own NSRuleEditor. NSPredicateEditor will be trickier as you get a lot of behavior built into what you need to override, but probably still possible.

+1
source

Source: https://habr.com/ru/post/1262597/


All Articles