Reputation: 95
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.
Upvotes: 3
Views: 707
Reputation: 135550
Confirmed. Cocoa's collection classes implement NSCopying
by creating a shallow copy. If you need a deep copy, you will have to implement it yourself.
Upvotes: 5