here’s the scenario, I have this array of Person objects. copyWithZone is implemented on Person and works as expected.
I have an array of Person objects, however when I create a copy of the array and modify things in original array (change attributes of a Person) it changes the copy as well. So my best guess is that when I call copyWithZone on NSArray, it does not call it on its elements. Please confirm.
Confirmed. Cocoa’s collection classes implement
NSCopyingby creating a shallow copy. If you need a deep copy, you will have to implement it yourself.