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

Popular posts from this blog

haskell - Using filter on an item in a list? -

tomcat6 - Exception when stopping container for a with Spring + Quartz + Tomcat web application -

c# - Binding attached property to IEnumerable -