views:

78

answers:

2

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.

+8  A: 

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

[self.itemsCopy addObjectsFromArray:self.items];
mipadi
+4  A: 

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)

Shaggy Frog