Predicate works with array controller but not fetch request
Predicate works with array controller but not fetch request
- Subject: Predicate works with array controller but not fetch request
- From: Kimo <email@hidden>
- Date: Thu, 21 Feb 2008 17:58:28 -0800
I have a Core Data app with an entity that contains a date attribute,
called startTime. I have a predicate defined as startTime >=
"today". If I apply that predicate to an array controller using
setFilterPredicate, it works fine. However, if I use the same
predicate with NSFetchRequest, it does not work (returns an empty
array). My code for fetching the data using a NSFetchRequest is
below. Why does this predicate work with an array controller but not
with a fetch request? All other predicates I have used work with both
the array controller and the fetch request. Just not when the
predicate is defined as startTime >= "today". Does anyone know why?
+(NSArray *)objectsForEntityName:(NSString *)name
predicate:(NSPredicate*)predicate
inContext:(NSManagedObjectContext *)context
{
NSEntityDescription *entity = [NSEntityDescription entityForName:name
inManagedObjectContext:context];
NSFetchRequest *req = [[[NSFetchRequest alloc] init] autorelease];
[req setEntity:entity];
[req setPredicate:predicate];
NSError *error = nil;
NSArray *array = [context executeFetchRequest:req error:&error];
return array;
}
Thanks in advance,
Kimo
_______________________________________________
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