You should take a look at the predicate syntax for subqueries. You cannot use the regular keyword ANY, as this allows you to map one column to two at a time.
NSString *keyValue = @"title"; NSString *valueValue = @"home"; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@"Page" inManagedObjectContext:_context]]; [request setPredicate:[NSPredicate predicateWithFormat:@"(SUBQUERY(attributes, $a, $a.key == %@ && $a.value == %@) .@count != 0)", keyValue, valueValue]];
The simplest predicate ANY attributes.key = "title" AND ANY attributes.value = "home" will not work, since it also returns pages with two dicts, for example. key = 'addr' / value = 'home' and key = 'title' / value = 'pete'.
source share