CoreData many-to-many relationship NSPredicate Exceptions
Posted
by user307550
on Stack Overflow
See other posts from Stack Overflow
or by user307550
Published on 2010-04-02T08:52:22Z
Indexed on
2010/04/05
15:43 UTC
Read the original article
Hit count: 436
I'm trying to model a Person/Team relationship. It's a many to many relationship since a person can belong to multiple teams and a team can have multiple people. As suggested by the doc I created an intermediate entity called TeamMember. I am now trying to run a query to see if I have a list of people, whether a pre-existing Team already exists for them so I'm not storing duplicate Teams in the database
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
NSEntityDescription *entity =
[NSEntityDescription entityForName:@"Team"
inManagedObjectContext:[pm managedObjectContext]];
[request setEntity:entity];
NSPredicate *predicate = nil;
predicate = [NSPredicate predicateWithFormat:@"ALL %K IN %@", @"teamMembers.person", players];
players is an NSSet of people that I'm trying to search
I'm getting the following exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported predicate ALL teamMembers.person IN { (entity: Person; id: 0x1334470 ; data: {
Ideally I would like them to match exactly and not just do an IN as well.
Any help would be greatly appreciated
© Stack Overflow or respective owner