iphone - 从 NSMutableArray 中的对象创建 NSArray

标签 iphone objective-c ios xcode

我有包含 10,000 个对象的 NSMutableArray,每个对象都有名称、详细信息等。 我想创建一个 NSArray,它只包含所有对象的名称。

最佳答案

使用KVC

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

查看 NSArray 的文档

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

关于iphone - 从 NSMutableArray 中的对象创建 NSArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10422628/

相关文章:

ios - 在 IOS 中将包含 NSDictionary 对象的 NSArray 转换为单个 NSDictionary

iphone - 滚动时 UITableviewCell 问题

iOS自定义形状导航栏

ios - 在 UISegmentedControl 中换行文本 (iOS 9+)

ios - 在底部为 UITableView 添加页脚

ios - 一次解析两个 (YouTube) JSON 链接

iphone - 如何设置 map View 的框架 - 在 iOS6 的谷歌 GMSMap 中

iphone - 无效的日期格式

iphone - 如何将带有 CAEmitterLayer 的 UIView 添加到我的游戏中?

iphone - 具有许多不同列表的 UIPickerView