2011-06-16 56 views
0

我有一張桌子'Person'和另一個Car,其中關係是一對多(一個人可能有很多車)。根據相關物品的屬性選擇物品

如何寫一個謂詞來讓所有擁有汽車的人(如果他們有更多的人)擁有某個屬性?

回答

1

像這樣的東西?

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