How to add an NSMutableArray to an NSMutableArray Objective-c

novicePrgrmr picture novicePrgrmr · Oct 23, 2011 · Viewed 44.2k times · Source

I am making the switch from Java to Objective-c, and I'm having some difficulty. I have searched this problem this without much success.

I have an NSMutableArray that stores NSMutableArrays. How do I add an array to the array?

Answer

August Lilleaas picture August Lilleaas · Oct 23, 2011

You can either store a reference to another array (or any type of object) in your array:

[myArray addObject:otherArray];

Or concatenate the arrays.

[myArray addObjectsFromArray:otherArray];

Both of which are documented in the documentation.