Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

From array of dictionaries, make array containing values of one key

I have an array of dictionaries. I would like to extract an array with all the elements of one particular key of the dictionaries in the original array. Can this be done without enumeration?

like image 375
RunLoop Avatar asked Apr 21 '10 04:04

RunLoop


1 Answers

Yes, use the NSArray -valueForKey: method.

NSArray *extracted = [sourceArray valueForKey:@"a key"];
like image 173
David Gelhar Avatar answered Oct 10 '22 16:10

David Gelhar