12. Copying

The Copying pattern is used to create new object instances by copying existing instances. The act of copying objects is not always as clear cut as you might expect. For example, if you copy an object that contains other objects, should the copy contain the exact same objects as the original, or should the copy contain copies of the objects in the original?

Copying serves as an alternative to the Two-Stage Creation pattern introduced in Chapter 3, “Two-Stage Creation,” and enables the Prototype pattern in Chapter 21, “Prototype.” Copying also plays a role in the Accessor pattern from Chapter 10, “Accessors.” At a higher level, user interface actions, like copy and paste or drag and drop, are often implemented by copying application ...

Get Cocoa Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.