如何在谓词中引用对象 ID



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

我的初始方法是错误的。应使用 NSManagedObject 子类化对象而不是它们的 ID。

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

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

向下滚动到"Cocoa Fundamental"并检查代码以查看Apple如何做到这一点。

最新更新