我对 NSPredicate 有疑问。
我使用此谓词来获取status=="Compare"
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription @"MyEntity"
inManagedObjectContext:context];
[request setEntity:entity];
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"status == %@",@"Created"];
[request setPredicate:predicate];
但是现在我想把所有结果都归结为" Created
" 或" Readed
"。
我怎么改变我的谓词?
答案 0 :(得分:0)
这会起作用吗?
[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
return [[evaluatedObject status] isEqualToString:@"Created"] || [[evaluatedObject status] isEqualToString:@"Readed"];
}];
答案 1 :(得分:0)
尝试
[NSPredicate predicateWithFormat:@"status IN %@",@[@"Created", @"Readed"]];