title: Core Data: NSPredicate for many-to-many relationship. ("to-many key not allowed here")
body: <p>I have two entities named "Category" and "Article" which have a many to many relationship. I want to form a predicate which searches for all articles where category.name is equal to some value. I have the following:</p>
  
  <pre><code> NSEntityDescription  *entityArticle   = [NSEntityDescription entityForName:@"Article" inManagedObjectContext:managedObjectContext]; 
   NSSortDescriptor  *sortDescriptor   = [[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES];
   NSArray     *sortDescriptors  = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
   NSPredicate    *predicate    = [NSPredicate predicateWithFormat:@"categories.name == [cd] %@", category.name]; 
  
   [request setSortDescriptors:sortDescriptors];
   [request setEntity:entityArticle];
   [request setPredicate:predicate];
  
   NSMutableArray *results = [[managedObjectContext executeFetchRequest:request error:nil] mutableCopy];
  
   if ([results count] &gt; 0)
    NSLog(@"Results found."); 
   else 
    NSLog(@"NO results found."); 
  
   [request release];
   [sortDescriptor release];
   [sortDescriptors release];
  </code></pre>
  
  <p>The error I receive is <code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here'</code></p>
  
  <p>Are there any options to retrieve the desired data?</p>