I have an array of Person objects (which has a number of attributes). I want to make another array with just the Person's "fullname" attribute. Is there a simple way to do this, other than the obvious one: iterate over the original array, and copy over the fullname one-by-one into another array? Can we do this initWithArray: and tell it to use the obje开发者_开发问答ct's fullname property when copying?
NSArray indeed has built-in method for that:
NSArray *nameArray = [personArray valueForKey:@"fullname"];
精彩评论