问题
how to use NSPredicate to satisfy multiple conditions
NSEntityDescription *entity = [NSEntityDescription entityForName:@"MessageData" inManagedObjectContext:managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"msg_id = %@",msg_id];
[fetchRequest setPredicate:predicate];
i need to fetch objects in which msg_id = values in a array
回答1:
You can do "msg_id IN %@", array
.
来源:https://stackoverflow.com/questions/6189005/nspredicate-multiple-items-from-an-array