3

I have two arrays and I would like to append one to the end of the other. How can I go about doing this?

self.itemsCopy = [self.items mutableCopy];

Will copy the array, but I would like to append self.items.

2
  • Isn't this just an extension of your original question? stackoverflow.com/questions/2976910/… Commented Jun 4, 2010 at 20:48
  • 1
    Joshua Nozzi: Nothing wrong with that. It is a separate question, regardless of its origins. Commented Jun 5, 2010 at 5:51

2 Answers 2

11

Assuming itemsCopy is an NSMutableArray that has already been created, you can do:

[self.itemsCopy addObjectsFromArray:self.items];
Sign up to request clarification or add additional context in comments.

Comments

5

Check out the docs for NSMutableArray:

addObjectsFromArray:

Adds the objects contained in another given array to the end of the receiver’s content.

(This won't be a deep copy, however)

Comments

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.