Looking for the most succinct way to convert an array of dicts to an array composed of a certain attribut开发者_如何转开发e of each dict. eg.
[ { name => 'Visa', value => 'VI' }, { name => 'Mastercard', value => 'MC' }]
=>
['Visa', 'Mastercard']
This should do the trick:
NSArray *nameArray = [yourArray valueForKey:@"name"];
valueForKey: Returns an array containing the results of invoking valueForKey: using key on each of the receiver's objects.
精彩评论