在Objective-C中合并NSArrays [英] Merging NSArrays in Objective-C

查看:79
本文介绍了在Objective-C中合并NSArrays的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSDictionary,其中每个键都指向一个数组。稍后,我想将所有值合并到一个数组中。有没有一种方法可以使用API​​做比说的更有效率的事情:

I have an NSDictionary where each key points to an array. I later want to merge all of the values into one array. Is there a way to use the API to do something more efficient than say:

NSArray *anArray = [someDictionary allValues];
NSMutableArray *newArray = [NSMutableArray array];
start outter loop on anArray
   start inner loop on objects in anArray
     add objectAtIndex to newArray


推荐答案

只需使用 [newArray addObjectsFromArray:anArray];

这篇关于在Objective-C中合并NSArrays的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆