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
Post a Comment