departments is an array of objects, then you can use
ANY in the predicate:
... OR (ANY departments.Name CONTAINS[cd] %@)
I have an app that correctly uses NSPredicate to filter an array and displays the resulting filtered array to the user.
Here is my NSPredicate code:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(Name CONTAINS[cd] %@) OR (Acronym CONTAINS[cd] %@) OR (departments.Name CONTAINS[cd] %@)",searchBar.text,searchBar.text,searchBar.text];
The problem comes when the user attempts to search by the
departments.Name property. I believe the problem is the way that I search through the array (ListData). The way that the array is formatted is:
The ListData array holds several objects with keys: Name, Acronym, and departments (which further has objects with a key: Name). I want to use NSPredicate to search through the ListData.Name, ListData.Acronym, AND ListData.departments.Name.
NOTE: There are a range of 0-10 departments which an object could contain. Not sure if this would cause any problems, but I would like to provide as much relevant information as possible.
How would I format the
NSPredicate predicateWithFormat: to search all three variables?