lately I work much with arrays and I'm wonder.. what's diffrences between those two lines.
NSArray *array = [NSArray arrayWithArray:someArray];
and
NSArray *array = [someArray copy];
Which of it is faster? What in case we have NSMutableArray
and mutableCopy
?
In addition to the other answers, also note, that when
someArray
is nil, the first line will makearray
point to an empty array and the second will make it point to nil. This might be an important difference, especially in mutable arrays.