Hi all,
I have to entities namely 'account' and 'event'.
The account has to-many relation to event and inverse to-one from event.
Now when I save a event object to account it is working nicely.
But when I fetch for events for particular related account it gives all the entities available which is not desirable behavior.
I am passing the currentAccount object as follows :
if (PrivarteController == nil) {
PrivarteController *aController = [[PrivarteController alloc]initWithNibName:@"PrivarteController"
bundle:nil];
self.PrivarteController = aController;
[aController release];
}
self.PrivarteController.shouldFetchNewCounts = YES;
self.PrivarteController.currentAccount = [self.fetchedResultsController objectAtIndexPath:indexPath];
[[self navigationController] pushViewController:self.PrivarteController animated:YES];
in that controller I am fetching for related events to an account like this :
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSString *predicateFormat = [NSString stringWithFormat:@"ddtype = 'Home'"];
NSPredicate *pred = [NSPredicate predicateWithFormat:predicateFormat];
[request setPredicate:pred];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"DDEvent" inManagedObjectContext:[self.currentAccount managedObjectContext]];
[request setEntity:entity];
[request setResultType:NSManagedObjectResultType];
NSError *error = nil;
NSArray *array = [[self.currentAccount managedObjectContext] executeFetchRequest:request error:&error];
In this request suppose I have two events of Home in account A and 2 events of Home in account B so instead of giving me 2 objects for each account it gives me all the 4 objects for both accounts so what is wrong with the query .
I have no clue what is going wrong ?
Thanks ,