2
我试图根据字段“guid”搜索子实体。 guid字段在父实体中定义。我想找到guid等于我传入的某个值的子实例,但它总是返回0值的结果。我假设核心数据没有看到guid属性,因为它在父实体中定义。NSPredicate搜索基于父实体的属性的子实体实例
这里是我的谓词:
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:CHILD_ENTITY inManagedObjectContext:managedObjectContext]];
[request setPredicate:[NSPredicate predicateWithFormat:@"(guid like '%@')", guid]];
NSError *error = nil;
NSArray *results = [managedObjectContext executeFetchRequest:request error:&error];
if (results != nil && results.count > 0)
return YES;
else
return NO;
是我的谓词格式错了吗?
谢谢!!!!!!通过继承我的意思是孩子是一种父类。所以报价是问题。为什么报价将它抛出? – MBU 2012-07-09 02:45:15
因为框架试图照顾他们,所以它可能翻倍:-) – 2012-07-09 02:49:48
啊我看到了。非常感谢你! – MBU 2012-07-09 04:10:00