O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Delegation

When you set the delegate property of the CLLocationManager and implemented the two location-finding methods in WhereamiViewController, you were using a design pattern called delegation. This is a very common pattern in Cocoa Touch, and many classes have a delegate property.

Delegation is an object-oriented approach to callbacks. A callback is a function that is supplied in advance of an event and is called every time the event occurs. Some objects need to make a callback for more than one event. For instance, the location manager wants to callback when it finds a new location and when it encounters an error.

However, there is no built-in way for two (or more) callback functions to coordinate and share information. This is the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required