For the More Curious: Pros and Cons of Callback Options

A callback, as you may remember from Chapter 4, is a chunk of code you supply in advance of an event occurring. When that event goes down, the chunk of code gets executed. While blocks have many more uses, you have seen in this chapter that they can be used as another approach to callbacks. Other approaches to callbacks you have seen are delegation, target-action pairs, and notifications. Each one has benefits and drawbacks compared to the others. This section will expand on these benefits and drawbacks so that you can pick the appropriate one for your own implementations.

First, let’s note that each of these approaches to callbacks are design patterns that transcend their implementations ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition 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.