Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 为多个键自动生成谓词行模板?_Cocoa_Core Data_Nspredicateeditor - Fatal编程技术网

Cocoa 为多个键自动生成谓词行模板?

Cocoa 为多个键自动生成谓词行模板?,cocoa,core-data,nspredicateeditor,Cocoa,Core Data,Nspredicateeditor,在我的核心数据管理对象模型中,我有一个实体Foo,它与实体Baz具有对多关系(与对多相反),名为Baz。Baz有一个名为“tag”的字符串属性。当我使用[nspredicateRowEditorTemplatesWithTributeKeyPath:[NSArray arrayWithObject:@“baz.tag”]inEntityDescription:FooDescription]为NSPredicateEditor创建行编辑器时,结果(如预期的那样)包含一个行模板,如 [Popup:b

在我的核心数据管理对象模型中,我有一个实体Foo,它与实体Baz具有对多关系(与对多相反),名为Baz。Baz有一个名为“tag”的字符串属性。当我使用
[nspredicateRowEditorTemplatesWithTributeKeyPath:[NSArray arrayWithObject:@“baz.tag”]inEntityDescription:FooDescription]
为NSPredicateEditor创建行编辑器时,结果(如预期的那样)包含一个行模板,如

[Popup:baz.tag][Popup:Contains | is | is not |……][TextField]


当我从弹出窗口中选择“Contains”时,带有谓词的查询将按预期工作。如果我选择任何其他弹出窗口(例如“is”),我会得到以下错误:“to many key not allowed here”。我可以使用
[nspredicateRowEditorTemplatesWithTributeKeyPath:inEntityDescription:][/code>还是必须手动构建行编辑器?

它看起来像是自动生成的模板(使用
[nspredicateRowEditorTemplatesWithTributeKeyPath:inEntityDescription:][/code>)无法生成正确的运算符。解决方案是使用
[nspredicateditorrowtemplate initWithLeftExpressions:righexpressionattributeType:modifier:operators:options://code>手动创建模板。对于给定的示例:

id template = [[NSPredicateEditorRowTemplate initWithLeftExpressions:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:@"baz.tag"]] rightExpressionAttributeType:NSStringAttributeType modifier:NSAnyPredicateModifier operators:keywordOperators options:0];