0

NSManagedObjects他のオブジェクトと特定の関係を持つセットを取得しようとしています。

だから私は4つの管理対象オブジェクトを持っています:UserPick、、、、。UserPick は、 、、 と個別に一対一の関係にあります。特定の , andを持つすべての を見つける必要がありますが、述語を正しく構造化できないようです:GameGroupUserGameGroupUserUserPickGameGroupUser

私はもう試した:

[NSPredicate predicateWithFormat:@"%K = %@, %K = %@, %K = %@",
UserPickRelationships.game, game,
UserPickRelationships.group, group,
UserPickRelationships.user, user]

と:

[NSPredicate predicateWithFormat:@"%K = %@, %K = %@, %K = %@",
UserPickRelationships.game, game.objectID,
UserPickRelationships.group, group.objectID,
UserPickRelationships.user, user.objectID]

最後に:

[NSPredicate predicateWithFormat:@"%K.%K = %@, %K.%K = %@, %K.%K = %@",
UserPickRelationships.game, @"objectID", game.objectID,
UserPickRelationships.group, @"objectID", group.objectID,
UserPickRelationships.user, @"objectID", user.objectID]

考えられるあらゆる組み合わせで%@andを使用してみました。%K私が今までに返すのは: NSPredicate cannot parse format string. これどうやってするの?

4

1 に答える 1

4

おそらく条件を「AND」で結合したいと思うでしょう:

[NSPredicate predicateWithFormat:@"%K = %@ AND %K = %@ AND %K = %@",
UserPickRelationships.game, game,
UserPickRelationships.group, group,
UserPickRelationships.user, user]

UserPickRelationships.game(それが文字列に評価されると仮定します"game")。

于 2014-05-27T16:11:43.090 に答える