3

私の Core Data マネージド オブジェクト モデルには、baz という名前のエンティティ Baz との対多関係 (対多逆数を持つ) を持つエンティティ Foo があります。Baz には「tag」という名前の文字列プロパティがあります。[NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:[NSArray arrayWithObject:@"baz.tag"] inEntityDescription:FooDescription]NSPredicateEditor の行エディターを作成するために使用すると、結果には (予想どおり) 次のような行テンプレートが含まれます

[ポップアップ: baz.tag] [ポップアップ: 含む|である|ではない|...] [テキストフィールド]

ポップアップから「含む」を選択すると、述語を含むクエリが期待どおりに機能します。他のポップアップ (「is」など) を選択すると、「to-many key not allowed here」というエラーが表示されます。行エディターを手動で使用できます[NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:]か、または手動で作成する必要がありますか?

4

1 に答える 1

4

自動生成されたテンプレート (を使用[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];
于 2008-10-22T18:18:27.603 に答える