iphone - Getting an NSArray of a single attribute from an NSArray -
i facing regular scenario.
i have nsarray has object of custom type, person. person class has attributes: firstname, lastname , age.
how can nsarray containing 1 attribute nsarray having person objects?
something like:
nsarray *people; nsarray *firstnames = [people getarrayofattribute:@"firstname" andtype:person.class]
i have solution of writing loop , fill in firstnames array don't want that.
nsarray handle using kvc
nsarray *people ...; nsarray *firstname = [people valueforkey:@"firstname"];
this give array of firstname values each entry in array
Comments
Post a Comment