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 with NSDates



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:
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.