ios - Search NSArray of NSDictionary. How to find using NSPredicate? -


i have nsarray. has 1 or more nsdictionary in each index. based on search input, want check whether contain value in contact_label inside contact_detail dictionary. this:

(   {      "contact_detail" =     {           "contact_is_in_phone" = 1;           "contact_label" = "tyler globussoft";           "contact_displayname" = "suzan arohh";      },      "last_msg_details" =     {            .....      };   },   {   } ); 

i have tired this. not getting result.

nsarray *contacts = self.dataarray; //your array of nsdictionary objects nspredicate *filter = [nspredicate predicatewithformat:@"contact_label = %@",stringvalue]; nsarray *filteredcontacts = [contacts filteredarrayusingpredicate:filter]; 

you can use

nsarray *contacts = self.dataarray; //your array of nsdictionary objects nspredicate *filter = [nspredicate predicatewithformat:@"contact_detail.contact_label = %@",stringvalue]; nsarray *filteredcontacts = [contacts filteredarrayusingpredicate:filter]; 

happy coding...


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -