Re: fetchRequest doesn't give same result as filterPredicate
Re: fetchRequest doesn't give same result as filterPredicate
- Subject: Re: fetchRequest doesn't give same result as filterPredicate
- From: Martin <email@hidden>
- Date: Wed, 3 Oct 2007 10:40:31 +0200
Problem solved :
I just do [context refreshObject:self mergeChanges:YES]; before the
fetchRequest and things work great.
Martin.
Hi,
My Core Data based application has the following data model :
- a "person" entity
- a "file" entity with a "downloadedAt" attribute
- a relationship between the two : person.files <-->> file.person
What I'd like to have is an array of persons that match the
following predicate :
"ALL files.downloadedAt == NULL"
The predicate works if it's applied to a NSArrayController using :
[personsController setFilterPredicate:[NSPredicate
predicateWithFormat:@"ALL files.downloadedAt == NULL"]];
But it doesn't work when I try to do the same thing with a
fetchRequest :
@implementation Person
- (void)test
{
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSManagedObjectContext *context = [self managedObjectContext];
NSError *err = nil;
NSArray *result;
[request setEntity:[NSEntityDescription entityForName:@"Person"
inManagedObjectContext:context]];
[request setPredicate:[NSPredicate predicateWithFormat:@"ALL
files.downloadedAt == NULL"]];
result = [context executeFetchRequest:request error:&err];
Log(@"%@",result);
Log(@"%@",err);
[request release];
}
@end
The following code just logs :
()
(null)
Meaning the array is empty and there is no error...
What am I missing ? Why are the two methods giving a different
result ?
Many thanks,
Martin.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden