Reputation: 5555
NOTE: employeename is a key in an array of multiply key value pair
NSPredicate to find result of all employee name when user type character wise search
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"employeename BEGINSWITH[cd] %@", searchtxtField.text];
NSArray *elementFound= [arr_employeeData filteredArrayUsingPredicate:predicate];
NSLog(@"arr_add_data=%@",arr_employeeData);
(
{
employeename = "Anoop";
employeeMobile = 11111111;
},
{
employeename = "Anoop singh";
employeeMobile = 11111111;
},
{
employeename = "Anoop kumar";
employeeMobile = 1133111111;
},
{
employeename = "Vijay kumar";
employeeMobile = 22222;
},
)
If your type A in search bar he will have to get all results employee name start with A and so on
Upvotes: 0
Views: 59
Reputation: 1144
I guess with your predicate is all Ok. But the result of filtered users will be in
NSArray *elementFound .
Just print it,and use it next in your program. Because this method return filtered array by predicate, but not change the original one. To change original one,
NSMutableArray * mutab = [[NSMutableArray alloc] initWithArray:arr_employeeData];
[mutab filterUsingPredicate:predicate];
And "mutab" array, will have filtered results
Upvotes: 2