title: Core Data: 'The left hand side for an ALL or ANY operator must be either an NSArray or an NSSet.'
body: <p>I have a method which queries Core Data if an object for today already exists.</p>
  
  <p>My code:</p>
  
  <pre><code>CoreDataHelper *cdh = [(MRMedSafeAppDelegate *) [[UIApplication sharedApplication] delegate] cdh];
  NSManagedObjectContext *context = [cdh context];
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
  
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"BMI" inManagedObjectContext:context];
  [request setEntity:entity];
  
  NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:[NSDate date]];
  NSInteger day = [components day];
  NSInteger month = [components month];
  NSInteger year = [components year];
  
  NSDateComponents *comps = [[NSDateComponents alloc] init];
  [comps setDay:day];
  [comps setMonth:month];
  [comps setYear:year];
  NSDate *today = [[NSCalendar currentCalendar] dateFromComponents:comps];
  
  NSLog(@"patient: %@", patient);
  
  NSPredicate *pred = [NSPredicate predicateWithFormat:@"(patient == %@) AND (erstellt_am == %@)", patient, today];
  [request setPredicate:pred];
  
  NSError *error = nil;
  NSArray *results = [context executeFetchRequest:request error:&amp;error];
  </code></pre>
  
  <p>The data model:</p>
  
  <p>bmi.patient is a To-One relationship with Patient.</p>
  
  <p>I don't understand what is wrong, there is not even a ALL or ANY clause in my predicate.</p>
  
  <p>Can someone enlighten me?</p>