Blocks vs. other callbacks

In Chapter 27, you learned about the callback mechanisms helper objects and notifications. Callbacks allow other objects to call methods in your object in response to events. While perfectly functional, these approaches break up your code. Pieces of your program that you would like to be close together for clarity’s sake usually are not.

The Callbacks program includes the following code that calls back to the zoneChange: method:

[​[​N​S​N​o​t​i​f​i​c​a​t​i​o​n​C​e​n​t​e​r​ ​d​e​f​a​u​l​t​C​e​n​t​e​r​]​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​a​d​d​O​b​s​e​r​v​e​r​:​l​o​g​g​e​r​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​s​e​l​e​c​t​o​r​:​@​s​e​l​e​c​t​o​r​(​z​o​n​e​C​h​a​n​g​e​:​)​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.