我有两个 NSManagedObjects 的场景,Arm 和 Person。他们之间是多对一的关系Person.arms和逆Arm.owner。
我想编写一个简单的 NSPredicate,其中我有 NSManagedObject *arm
并且我想获取该 ARM 所属的 NSManagedObject *person
到。我可以制作文本表示并查找它,但是有没有更好的方法可以通过身份查找它?也许是这样的?
NSEntityDescription *person = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:MOC];
NSPredicate *personPredicate = [NSPredicate predicateWithFormat:@"%@ IN arms", arm];
干杯
尼克
最佳答案
I've got the scenario with two NSManagedObjects, Arm and Person. Between them is a many-to-one relationship Person.arms and inverse Arm.owner.
I'd like to write a simple NSPredicate where I've got the
NSManagedObject *arm
and I'd like to fetch theNSManagedObject *person
that this arm belongs to.
那就是myArm.owner
。不需要谓词;这就是逆关系的用途。
关于iphone - NSPredicate by NSManagedObject 用于多对一查找,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2571477/