如何在谓词中引用对象id?

时间:2012-12-02 21:57:59

标签: ios core-data

我需要连接2个entites。第一个 - Player(attr =“name”),第二个 - Profiles(attr:“player_id”,“command_id”和其他内容)。在个人资料和玩家之间存在关系"player"。我想显示配置文件实体但是使用播放器名称而不是player_ids。 player_id是[[[_player objectID] URIRepresentation] absoluteString]。我该如何致电[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"player_id==player.<object id>"]]

2 个答案:

答案 0 :(得分:1)

我最初的做法是错误的。应该使用NSManagedObject子类对象而不是它们的ID。

答案 1 :(得分:0)

我认为你可能会追随的是Apple的谓词变量替换。

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdImporting.html

向下滚动到“Cocoa Fundamental”并查看代码以了解Apple是如何做到的。

相关问题