gpt4 book ai didi

iphone - NSPredicate by NSManagedObject 用于多对一查找

转载 作者:行者123 更新时间:2023-12-03 18:05:42 24 4
gpt4 key购买 nike

我有两个 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 the NSManagedObject *person that this arm belongs to.

那就是myArm.owner。不需要谓词;这就是逆关系的用途。

关于iphone - NSPredicate by NSManagedObject 用于多对一查找,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2571477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com