它看起来像是自动生成的模板(使用
[NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:]
)无法生成正确的运算符。解决方案是使用手动创建模板
[NSPredicateEditorRowTemplate initWithLeftExpressions:rightExpressionAttributeType:modifier:operators:options:]
. 对于给定的示例:
id template = [[NSPredicateEditorRowTemplate initWithLeftExpressions:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:@"baz.tag"]] rightExpressionAttributeType:NSStringAttributeType modifier:NSAnyPredicateModifier operators:keywordOperators options:0];