1

I wrote the following predicate for the following structure, not sure if its working correctly:

I have a Car.h managedobject

Car.h - name, make, model.

toCarParts relationship - CarPart.h - wheel, tire, mirror, etc...

i have an array with many Car.h objects I want to find only those that have a tire (so i have to look through toCarParts at all objects, and if any of the CarParts match my query, I need to pull that car into a results array)

will this predicate do this?

 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY toCarParts.name == [c] %@", carPartString];

Thank you in advance

William Falcon
  • 9,813
  • 14
  • 67
  • 110

1 Answers1

1

I believe this should work for you.

NSPredicate *predicate = 
   [NSPredicate predicateWithFormat:@"ANY toCarParts.name like %@", carPartString];
Bejmax
  • 945
  • 7
  • 16