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
?
Which of it is faster?
Don't worry about it. Premature optimization.
The main difference: the first approach results in an autoreleased "copy" that you don't own and don't have to release, while you do own the object created on the second line. Both arrays will be immutable, by the way.