I have an NSMutabelArray
with some objects in it as a property of my View-Controller
.
Now I pass this array when I push this VC.
I initially made it assign.
but now I needed to modify the array whenever the device rotates, in the VC without affecting the one in previous VC. so made it a copy property.
now I was individually changing the objects in the array.
but somehow..the array in my prev VC was also changing.
I had to create a new NSMutabelArray
with modified objects and had to set to my property.
Is it that copy attribute just makes another array with same references of objects added to the array ?
The copy
attribute means the property will be assigned the object returned after sending the copy
message to the object that was passed in. Whether that means deep or shallow depends on the object getting copied. The Foundation collections create shallow copies because that allows copy
to be implemented as retain
for immutable collections.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With