How to add an NSMutableArray to an NSMutableArray Objective-c How to add an NSMutableArray to an NSMutableArray Objective-c xcode xcode

How to add an NSMutableArray to an NSMutableArray Objective-c


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.


Since an array is just an object like any other:

[myContainerMutableArray addObject:someOtherArray];

Or if you want to concatenate them:

[myFirstMutableArray addObjectsFromArray:otherArray];


You add it like any other object.

NSMutableArray *innerArray = [NSMutableArray array];NSMutableArray *outerArray = [NSMutableArray array];[outerArray addObject:innerArray];