Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

Thanks,

Eric

share|improve this question

4 Answers

up vote 7 down vote accepted

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

[myArray addObject:otherArray];

Or concatinate the arrays.

[myArray addObjectsFromArray:otherArray];

Both of which are documented in the documentation.

share|improve this answer

Since an array is just an object like any other:

[myContainerMutableArray addObject:someOtherArray];

Or if you want to concatenate them:

[myFirstMutableArray addObjectsFromArray:otherArray];
share|improve this answer

You add it like any other object.

NSMutableArray *innerArray = [NSMutableArray array];
NSMutableArray *outerArray = [NSMutableArray array];
[outerArray addObject:innerArray];
share|improve this answer

[YourArray addObjectsFromArray:OtherArray];

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.