简体   繁体   中英

Create NSArray From Objects in NSMutableArray

I have NSMutableArray with 10,000 objects, each object has Name, Details, ...etc. I want to Create an NSArray Which contains ONLY the Names of all objects.

Use KVC

NSArray *names = [myArray valueForKey:@"name"];

Check the docs for NSArray

valueForKey:
Returns an array containing the results of invoking valueForKey: using key on each of the array's objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM