danw
danw

Reputation: 83

Setting an array to another array

apologies if this has been asked multiple times but I haven't managed to find an answer.

If I have an NSArray called array1, is there any difference between these 2 methods:

NSArray *array2 = [NSArray alloc] initWithArray:array1];

and:

NSArray * array2 = array1;

Thanks

Upvotes: 0

Views: 131

Answers (1)

Marcos Crispino
Marcos Crispino

Reputation: 8218

Yes.

The first creates a new array.

Te seconds creates a new reference to the original array.

Upvotes: 2

Related Questions