質問

コアデータ管理オブジェクトモデルには、bazという名前のエンティティBazと対多関係(対多逆関係)のエンティティFooがあります。 Bazには、「タグ」という名前の文字列プロパティがあります。 [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:[NSArray arrayWithObject:@" baz.tag"] inEntityDescription:FooDescription] を使用してNSPredicateEditorの行エディターを作成すると、結果には(予想どおり)行テンプレートが含まれます

[ポップアップ:baz.tag] [ポップアップ:次を含む| is | is not | ...] [テキストフィールド]

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

役に立ちましたか?

解決

[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];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top