Changes

Copying Objects in Objective-C

7 bytes removed, 18:50, 16 November 2009
no edit summary
Now when executed, the above code creates a copy of the object referenced by ''account1'' and assigns a pointer to the new object to variable ''account2''.
== Performing a Deep Object Copies Copy ==
The copying techniques we have looked at so far in this chapter are referred to as ''shallow copies''. This means that if the ''copy'' or ''mutableCopy'' methods are used to copy an object that itself contains instance variables that are themselves pointers to objects, the copy will also contain pointers to the same objects. To better understand this concept consider an NSArray object that contains as its elements pointers to three string objects: