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
  • DownloadDownload
  • PrintPrint

Solution

When working with Objective-C, it is important to remember that sending a message to an object is not the same thing as invoking a method. When an object receives a message, usually a method is invoked to handle the message. However, this is not always the case. For example, if an object doesn’t implement a particular method, then there is no method that can be invoked, and a runtime exception is raised instead. Because of the flexibility of the Objective-C runtime, it is possible for messages to be delayed, rerouted to other receivers, or even ignored.

It is sometimes useful to think of Objective-C messages as if they were analogous to a real-world message. For example, a secretary might receive messages for a corporate executive. The messages might be handled by the secretary, passed on to the executive as-is, or changed before being passed on. A particularly important message might be copied and sent on to multiple recipients. In Objective-C, all these scenarios are possible. Chapter 27, “Proxies and Forwarding,” demonstrates how many of these situations can be implemented.


  

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