Reputation: 583
Here, try to fetch record from my two entity name is: Resgistration & Unique. and relationship name is roshan between them. When m execute it display the error : 'NSInvalidArgumentException', reason: 'to-many key not allowed here'
NSManagedObjectContext *context = [appDelegate manageObjectContext];
NSError *error = nil;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"roshan.number == %@", @"1"];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Resgistration" inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDescription];
[request setPredicate:predicate];
[request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObjects:@"Unique",nil]];
[request setIncludesSubentities:YES];
NSArray* returnArray = [context executeFetchRequest:request error:&error];
if([returnArray count] > 0) {
Resgistration* reg = [returnArray objectAtIndex:0];
NSLog(@"%@ %@", reg.name, reg.number);
}
Upvotes: 1
Views: 1144
Reputation: 8563
roshan
is a to-many relationship so the statement "roshan.number == 1" is ambiguous.
Upvotes: 3