I have NSMutableArray of dictionaries:
something like :
(
{
"Key1" = "Name1";
"Key2" = "Age1";
"Key3" = "Address1";
},
{
"Key1" = "Name2";
"Key2" = "Age2";
"Key3" = "Address2";
},
{
"Key1" = "Name3";
"Key2" = "Age3";
"Key3" = "Address3";
}
)
Using this code to search key 1 value. User can type even alphabet and I have to search the all the dictionary with key containing that alphabet.
NSPredicate *filter = [NSPredicate predicateWithFormat:@"'Key1' =[cd] %@", searchstring];
NSArray *filteredContacts = [DisplayArray filteredArrayUsingPredicate:filter];
But this predicate is not working. please help.
Try and check using below code.
Use contains[c] in NSPredicate like below:
NSPredicate *filter = [NSPredicate predicateWithFormat:@"Key1 contains[c] %@ ",searchstring];
NSArray *filteredContacts = [DisplayArray filteredArrayUsingPredicate:filter];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With