objective c - ObjectiveC/iphone: convert an array of dicts to an array composed of a certain attribute of each dict -


looking succinct way convert array of dicts array composed of attribute of each dict. eg.

[ { name => 'visa', value => 'vi' }, { name => 'mastercard', value => 'mc' }] =>  ['visa', 'mastercard'] 

this should trick:

nsarray *namearray = [yourarray valueforkey:@"name"]; 

valueforkey: returns array containing results of invoking valueforkey: using key on each of receiver's objects.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -