Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Predicate works with array controller but not fetch request



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.