Say you have a class Person (with name, age, etc), and an array called PeopleArray which has several individual Person’s.
What’s the easiest way of extracting each Person’s name (for instance) and putting it into an array.
Psuedocode is:
nameArray = every Person's name, from the array PeopleArray
Edit: I’ve found a better solution than the answers I previously posted
Sends -name to every element of peopleArray and builds a new array of the results
Documentation
One way, use fast enumeration:
Another way, to distinguish my answer from the identical one posted just before mine 🙂
Create a method on Person called addNameToArray: and use makeObjectsPerformSelector:
Disappointingly there seems to be no equivalent to the map function.