0
我有一个实体&三个属性叫做name,version,Company。 我想过滤公司属性的值,如“快餐”。使用NSPredicate如何从核心数据中过滤值
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Device" inManagedObjectContext:managedObjectContext];
[request setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"('company' contains[c] 'Fast Foood')"];
[request setPredicate:predicate];
NSLog(@"Pre %@",predicate);
NSError *error = nil;
NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil) {
// Handle the error.
}
// Set self's events array to the mutable array, then clean up.
[self setDataarr:mutableFetchResults];
但我不能做这个PLZ帮助我。
你好....马丁..我们可以聊这个问题 – 2013-02-23 14:36:55
@AbhishekRathore:如果你描述的问题我会尽力帮忙。 – 2013-02-23 14:38:27
其实我想根据一个类别获取信息,例如,让我们拿一个餐馆菜单,在这里我想根据管理员准备的物品清单输入的值显示菜单卡上的值。 例如,在甜品类别中插入冰淇淋,将桃子汤插入汤类中。这些项目需要按照选择的类别在菜单中显示。 – 2013-02-23 14:44:20