我的核心数据中有目录和类别实体
他们有一个多对多的关系
我想获取字段 categoryStatus="active" 并参与 catalogue.categories 的特定类别
什么是正确的谓词?
或没有 fetch > catalogue.categories where categoryStatus=@"active"
c# aCatalogue.categories.Where(c=>c.categoryStatus == "active") 的等价物
我尝试这样的事情,但没有运气
-(NSArray *) CategoryGetListWhereStatusActive4Catalogue:aCatalogue2DisplayCategories
{
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Category" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"([catalogues containsObject:%@) AND (categoryStatus == %@)" , aCatalogue2DisplayCategories, @"active"];
[fetchRequest setPredicate:predicate];
return [self performFetch:fetchRequest withContextObject:context];
}