objective c - Array of objects from array conatining objects with values contained in another array -


is there possibility array of objects without loops like:

imagine have arrays: : [1,2,3,4]

b -< array of dictionaries

b : [["code",a,"id",4],["code", b, "id", 2],["code", c","id",4"],["code", d,"id",5"]];

and want array ids b in result array like: c: [["code",a,"id",4],["code", b, "id", 2],["code", c","id",4"]]

does know how without loops? maybe predicates or something?

yes, predicates trick here:

[b filteredarrayusingpredicate:[nspredicate predicatewithformat:@"id in %@", a]]; 

note works if work nsnumbers rather straight ints - cannot stored in nsarrays or nsdictionaries. (nsstrings work well.)


Comments