Reputation: 3663
I have a NSMutableArray
it has several dictionary objects like this.
"DisplayName": "ART42 - Jomon Williams",
"DisplayName2": "Jomon Williams",
"EmployeeNumber": "ART42",
"Designation": "Senior Executive - Systems",
I have a UITextField
when its text changing I want to reload my UITableView
with search filtered array. For Searching I did something like this. When my text is changing im doing this.
NSPredicate *exists = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", searchText];
NSLog(@"Predicate-------%@",exists);
NSArray *aList = [mutArrayStaff filteredArrayUsingPredicate:exists];
I want to search by DisplayName2
key. Everytime my aList
array is empty. How can I write my predicate correctly inorder to search on DisplayName2
Please help me. Thanks
Upvotes: 2
Views: 407
Reputation: 52223
Assuming the mutArrayStaff
is a list of dictionaries, each of them containing DisplayName2
as the key, you can do the following:
NSPredicate *exists = [NSPredicate predicateWithFormat:@"(DisplayName2 CONTAINS[cd] %@)", searchText];
Upvotes: 3