April 2010
Beginner to intermediate
480 pages
10h 9m
English
In this chapter, we introduce delegation, a recurring design pattern of Cocoa Touch development, and demonstrate its use with the Core Location service, which provides the location-finding features of the iPhone.
We spend a lot of time sending messages to objects. Sometimes, however, we want objects to send messages to us — a callback. A callback is a function that is triggered when an event occurs. Usually, this is an event that happens in response to user input. We don’t exactly know when this event might occur, but we set up a callback so that when it does occur, our code will be called. In some systems, callbacks are sent to objects that are known as listeners.
In Cocoa Touch, callbacks are implemented ...
Read now
Unlock full access