I have a Person
Object which has two NSString
properties; firstName and lastName
.
I\'m currently using an NSPredicate
like so
you can concatenate the fields into two common fields (firstLastName and lastFirstName )
- (NSString *)firstLastName {
return [NSString stringWithFormat:@"%@ %@", self.firstName, self.lastName];
}
- (NSString *)lastFirstName {
return [NSString stringWithFormat:@"%@ %@", self.lastName, self.firstName];
}
and then filter on this fields using 'contains[cd]'
[NSPredicate predicateWithFormat:@"(firstLastName contains[cd] %@) OR (lastFirstName contains[cd] %@)" , self.searchBar.text, self.searchBar.text];