Merging multiple localized left keys in the same NSPredicateEditorRowTemplate?

I am trying to replicate a Finder NSPredicateEditor metadata search in an application.

I would rather get the exact NSPredicateEditor Finder for free , but if someone does not have a better answer to this question, it seems I will have to copy the Finder search as best as possible.

When working with mirroring the Kind option, I run into a problem. I start by saving the Finder Spotlight search with all the available Kind options.

Each option is <code> View </code>, in a Finder search.

When I Get Info in the received saved search folder, the request is listed as:

 (kMDItemContentTypeTree=com.apple.application) && (kMDItemContentTypeTree=public.archive) && (kMDItemContentTypeTree = public.content) && (_kMDItemGroupId = 8) && (_kMDItemGroupId = 9) && (_kMDItemGroupId = 13) && (_kMDItemGroupId = 7) && (_kMDItemGroupId = 10) && (_kMDItemGroupId = 11) && (_kMDItemGroupId = 12) && (kMDItemContentTypeTree = public.text) && (kMDItemKind = "my_Kind_custom_text*"cdw) 

The problem I see is that the only user-displayed text “Kind” contains several key paths that are used in the resulting NSPredicate based on which value is selected.

A "view" can represent (at least) kMDItemContentTypeTree , _kMDItemGroupId or kMDItemKind .

When I create an NSPredicateEditorRowTemplate , I pass in an array of left expressions, operators, and valid expressions. Then a line template is created containing all possible permutations on the left / operator / right.

(Note: I create all of the NSPredicateEditorRowTemplate programmatically, not in Interface Builder ).

Finder not , creating all possible permutations of 3 left keys and 12 right values. It selectively assigns a specific left key based on the value selected on the right.

I localize the string patterns using the NSRuleEditor formattingDictionary property based on the manual found here: http://funwithobjc.tumblr.com/post/1482915398/localizing-nspredicateeditor p>

I can assign the same localization to “View” to two different path expressions in two different NSPredicateEditorRowTemplate s.

When I have two line patterns localized in “Good” using the same left key path expression, the following quote “Pattern merging” is true, and only one “View” appears in the list, The correct pop-up window is a collection of all the two templates .

two-line patterns, one key path, the same localization

At run time, NSPredicateEditor will combine the templates together, and a second pop-up window will display the union of all the operators of your date templates. http://www.cocoabuilder.com/archive/cocoa/282859-nspredicateeditorrowtemplate-and-dynamic-templateviews.html

However, when I create two string patterns, both are localized in Good using different expressions on the left key path, instead I get two Look strings in my popup on the left. Templates are not combined.

two-line patterns, two key paths, the same localization

How do I repeat the behavior of the finder? I need to somehow combine the left key paths if they have the same localization, even if they represent different paths / key expressions, the result is a single line pattern with several left key paths, each with independent sets of correct values.

+5
source share

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


All Articles