title: Core Data - filtering a To-Many Relationship using Predicates
body: <p>I have the following two entities in my Core Data Model:</p>
  
  <pre><code>Manufacture {name, ...other attributes}
  Product {name, .... other attributes}
  </code></pre>
  
  <p>I have setup a One to Many Relationship: </p>
  
  <pre><code>Manufacturer.manufactures &lt;------&gt;&gt; Product.manufacturedBy
  </code></pre>
  
  <p>I am trying to build a predicate to return all Products belonging to Manufacturers that match a search string. E.g. if there are two Manufacturers, "King Nut", and "Queen Nut" then a search on "Nut" should return all products made by both King Nut and Queen Nut.</p>
  
  <p>My predicate works perfectly when my filter is on the Product entity, however I cannot get any predicate to work when filtering on the Manufacturer entity. The result set is empty.</p>
  
  <pre><code>NSEntityDescription *entity = [NSEntityDescription entityForName:@"Product" inManagedObjectContext:[GBKDB context]];
  searchValue = @"nut";
  NSString *wildcardString = [NSString stringWithFormat:@"*%@*", searchValue];
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>    predicate = [NSPredicate predicateWithFormat:@"manufacturedBy.name CONTAINS[cd] %@",searchValue];
      predicate = [NSPredicate predicateWithFormat:@"manufacturedBy.name like %@",wildcardString];
      predicate = [NSPredicate predicateWithFormat:@"manufacturedBy.name matches %@",wildcardString];
      predicate = [NSPredicate predicateWithFormat:@"ALL manufacturedBy.name like %@",wildcardString];
      predicate = [NSPredicate predicateWithFormat:@"ALL manufacturedBy.name like[cd] %@",@wildcardString];
  </code></pre>