我想为核心数据查询构建 NSPredicate ,该查询应检索其1:n关系estType.consHistory.consType <> NIL *的所有IBEstPeriod管理对象。
不幸的是,我还没有找到任何关于这样的NSPredicate外观的线索。您有什么想法或建议吗?
谢谢!
最佳答案
对谓词中的多对关系使用“ANY”:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"IBEstPeriod" inManagedObjectContext:context]];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"ANY estType.consHistory.consType != nil"]];
NSArray *fetchResult = [managedObjectContext executeFetchRequest:fetchRequest error:nil];
关于objective-c - NSPredicate检索其1:n关系中的属性不是NIL的所有对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10234454/