predicate with NSDates
predicate with NSDates
- Subject: predicate with NSDates
- From: Andres <email@hidden>
- Date: Thu, 18 Oct 2007 16:57:11 -0400
Hello,
My Employee entity has a too many relationship called "myVacations" to a
Vacation entity which has date attributes "startDate" and "endDate". I want
to find out which employees are on vacation on a specific NSDate. I am
having trouble with the predicate below. What's the correct predicate
format?
NSDate *today = [NSDate date];
NSEntityDescription *entityDescription = [NSEntityDescription
entityForName: @"Employee" inManagedObjectContext: managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity: entityDescription];
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(
myVacations.startDate < %@) AND ( myVacations.endDate > %@) ", today,
today];
[request setPredicate: predicate];
NSError *error = nil ;
NSArray *employeesOnVacationToday = [managedObjectContext
executeFetchRequest:
request error: &error];
I get the following error:
-[NSCFArray compare:]: selector not recognized [self = 0x3d3690]
Thanks!
_______________________________________________
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