我有两个类,ClassA和ClassB,关系如下:
我需要查询所有count>10的ClassA的bObjects中name为hello的ClassB的对象。
请问能不能用一个NSPredicate来表示这个查询?
我有两个类,ClassA和ClassB,关系如下:
我需要查询所有count>10的ClassA的bObjects中name为hello的ClassB的对象。
请问能不能用一个NSPredicate来表示这个查询?
脑补的,没测试。。。不好用请更正我
NSEntityDescription *entity = [NSEntityDescription entityForName:@"ClassB" inManagedObjectContext:context]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:entity]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(name = %@) AND (aObjects.count > 10)", @"hello"]; [fetchRequest setPredicate:predicate];
看了苹果的文档,里面写的例子:
所以,我觉得查询应该是: