1

I call two feeds that both return an NSMutableArray, I then need to make the two arrays into one.

NSMutableArray *array1 = [JSONWrapper downloadFeed];
NSMutableArray *array2 = [JSONWrapper downloadFeed];

// something like: array1 += array2

2 Answers 2

12

Use -addObjectsFromArray::

[array1 addObjectsFromArray:array2];
Sign up to request clarification or add additional context in comments.

Comments

5
NSArray *newArray = [array1 arrayByAddingObjectsFromArray:array2];

1 Comment

This is the message you would send if neither array were mutable, or if you did not want to mutate either array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.