iphone - How to filter array of NSDictionary for key separated by comma -


i have array of nsdictionary.nsdictionary has key named multiple_image key contain string separated ,.

i want set of array contain 123.png multiple_images key. can 1 show me how using nspredicate or without predicate.

//array  {     image = "<uiimage: 0xf72df30>";     active = yes;     "admin_id" = 169;     "category_id" = 32;     "chef_id" = 175;     descr = "cool tea cool down mind.";     id = 110;     "multiple_images" = "jellyfish.jpg,345.png";     name = "southern sweet ice tea";     price = 160;     rating = 3;     selected = 0;     "subcat_id" = 23;     "tag_id" = 45;     "tax_id" = 10;     "tax_value" = "12.00"; },     {     image = "<uiimage: 0xf72ebd0>";     active = yes;     "admin_id" = 169;     "category_id" = 31;     "chef_id" = 175;     descr = "ingredients almonds or cashews. no hydrogenated stuff, no weirdo ingredients";     id = 107;     "multiple_images" = "jellyfish.jpg,123.png";     name = "butter chicken";     price = 300;     rating = 3;     selected = 0;     "subcat_id" = 24;     "tag_id" = 43;     "tax_id" = 9;     "tax_value" = "0.00"; },     {     image = "<uiimage: 0xf72f870>";     active = yes;     "admin_id" = 169;     "category_id" = 31;     "chef_id" = 173;     descr = "raw vegetables  including carrots, cucumbers.";     id = 100;     "multiple_images" = "jellyfish.jpg,shake.png,";     name = salads;     price = 50;     rating = 3;     selected = 0;     "subcat_id" = 22;     "tag_id" = 44;     "tax_id" = 9;     "tax_value" = "0.00"; } 

using predicates,

[array filteredarrayusingpredicate:[nspredicate predicatewithformat:@"multiple_images contains '123'"]]; 

using predicates, blocks

    nsarray *filtered = [test filteredarrayusingpredicate:[nspredicate predicatewithblock:     ^bool(nsdictionary *evaluatedobject, nsdictionary * bindings) {         nsstring *key = @"123";         return ([evaluatedobject[@"multiple_images"] rangeofstring:key].location != nsnotfound);     }]]; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -