NSPredicate to filter NSS master data relationship by attribute
I have a relationship many-to-many
with two objects. One of them is Person
, the other is Clubs
. I want to write predicate
which will find all Person
entities that are in a specific one Club
. I also want to check the person attribute position
.
Here's what doesn't work:
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"Person" inManagedObjectContext:self.managedObjectContext]];
[request setPredicate:[NSPredicate predicateWithFormat:@"position CONTAINS[cd] %@ AND IN %@", @"manager", self.clubs.people]];
NSArray *results = [self.managedObjectContext executeFetchRequest:request error:nil];
Fail on error:
Application terminated due to uncaught exception "NSInvalidArgumentException", reason: "Unable to parse format string" title CONTAINS [cd]% @AND IN% @ "'
I know I am doing something wrong here, any help?
source to share