0
votes

I have a question about NSPredicate.

I use this predicate to take all result with 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];

but Now I would to take all result that status is equal to "Created" OR "Readed". How I have to change my predicate?

2

2 Answers

0
votes

Will this do the trick?

[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
  return [[evaluatedObject status] isEqualToString:@"Created"] || [[evaluatedObject status] isEqualToString:@"Readed"];
}];
0
votes

Try

[NSPredicate predicateWithFormat:@"status IN %@",@[@"Created", @"Readed"]];