I try to understand when I need use copy
? I thought that copy
allocate new memory, but it doesn't. So, for example:
NSArray *array = @[@"111", @"111"];
NSArray *array1 = array.copy;
NSMutableArray *array2 = array.copy;
NSMutableArray *array3 = array.mutableCopy;
NSArray *array4 = array.mutableCopy;
New memory allocated only for array3 and array4. So, I can do for array1 and array2 simply:
NSArray *array1 = array;
NSMutableArray *array2 = array;
When I can use copy, it is only make immutable array2, when it will be helpfull for me?