2011-06-16 87 views
0

我有一张桌子'Person'和另一个Car,其中关系是一对多(一个人可能有很多车)。根据相关物品的属性选择物品

如何写一个谓词来让所有拥有汽车的人(如果他们有更多的人)拥有某个属性?

回答

1

像这样的东西?

NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]; 
NSString   *str  = @"ANY cars.property == 'value'"; 
NSPredicate   *predicate = [NSPredicate predicateWithFormat:str]; 
...