Chapter 12: Copying

Properly copying an object poses some questions, the most important of which is whether to make a shallow or deep copy. If an object has pointers to other objects, a shallow copy of the object contains pointers to the same objects as the original, while a deep copy involves making copies of the objects that the original pointers refer to.

Archiving makes deep copies, since all the pointed-to objects have to be stored in the archive so they can then be restored, probably to different memory locations than the originally.

The first two example programs in this chapter are command-line tools, which take ~5 minutes each to type in and run. The other examples also come from WordPuzzle.

This chapter ends the section on Fundamental Patterns, the ones that are basic to any Cocoa program. The next section covers patterns for decoupling objects so that they aren’t unnecessarily interdependent.

Advertisements
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s