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

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -