Reputation: 83
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
Reputation: 8218
Yes.
The first creates a new array.
Te seconds creates a new reference to the original array.
Upvotes: 2