Search code examples
objective-cioscocoa-touchnsarray

extracting properties from NSArray of objects


Is there any of way (other than looping) of extracting a particular property of all objects in an array. So say there in an array of people. I want to extract all their first names into an array.


Solution

  • Key Value coding will help you with that:

    NSArray *result = [people valueForKey:@"firstname"];