I have a one to many relationship between Games and Players. There is a relationship on Games to Players called players.
Games <-->> Players
The Games entity has a relationship called players. Players has an attributed named 'order'
I am unable to use a predicate to query on the relationship. Here is the code I am using:
-(NSArray *)returnPlayerLastAtBat: (int)rosterNo
{
NSError *error;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Games" inManagedObjectContext:managedObjectContext];
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(finished = '%d') and (players.order = '%d')",0,rosterNo];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate:predicate];
NSArray* result = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
[fetchRequest release];
return result;
}
Not sure what I am doing wrong- I am able to work with predicated throughout my project- but this one has been stuck.