I have a set of users in CoreData and an search field in my application. User has the properties firstname and name.
Currently I have a predicate like \"user.name CO
I had the same problem and solved it like this:
In my NSManagedObject class (user) I added the following method, merging the two values into a single string:
- (NSString *)name
{
return [NSString stringWithFormat:@"%@ %@", self.firstname, self.lastname];
}
Then you'll only need the following lines to match against your list, which is in my case an NSArray with user objects:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name contains[c] %@", searchString];
NSArray *filteredUsers = [users filteredArrayUsingPredicate:predicate];