Graphics Programs Reference
In-Depth Information
Also, with a target-action pair, the action message can be any message. In delegation, an
object can only send its delegate messages from a specific set listed in a
protocol
.
Protocols
For every object that can have a delegate, there is a corresponding
protocol
that declares
the messages that the object can send its delegate. The delegate implements methods from
the protocol for events it is interested in. When a class implements methods from a pro-
tocol, it is said to
conform to
the protocol.
The protocol for
CLLocationManager
's delegate looks like this:
// Note that we omitted a few methods from
// the real declaration of this protocol
// for brevity's sake
@protocol CLLocationManagerDelegate <NSObject>
@optional
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation;