Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Copying > Consequences

Consequences

The ability to copy objects is almost as fundamental as the ability to allocate and initialize new instances. Cocoa relies on framework level conventions to allocate and initialize new instances as explained in Chapter 3. The Copying pattern also relies on mere conventions established by the Cocoa frameworks. The Copying pattern enables the use of value semantics with objects and is used in the implementation of Accessors and the Prototype pattern. However, correct implementation of copying conventions requires some forethought by class designers. Support for Cocoa’s reference counted memory management must be considered in the implementation of the Copying pattern.

The interdependence of Objective-C 2.0 properties and the NSCopying protocol blurs the lines between framework features and compiler level language support. Prior to Objective-C 2.0, it was possible to use every feature of the Objective-C language without using Cocoa frameworks at all. Apple’s implementation of Objective-C 2.0 depends on the NSCopying protocol and the Copying pattern as implemented by Cocoa. The source code for the Objective-C 2.0 compiler is available from the Gnu Compiler Collection at http://gcc.gnu.org/. Future versions may implement Objective-C 2.0 properties syntax without dependence on Cocoa-specific protocols.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint