The Responder Chain

In Chapter 5, we talked briefly about UIResponder and the first responder. A UIResponder can receive touch events. UIView is one example of a UIResponder subclass, but there are many others, including UIViewController, UIApplication, and UIWindow. You are probably thinking, But you can’t touch a UIViewController. It’s not an on-screen object! You are right – you can’t send a touch event directly to a UIViewController, but view controllers can receive events through the responder chain. (By the way, you get two bonus points for keeping the view controller and its view separate in your brain.)

Every UIResponder has a pointer called nextResponder, and together these objects make up the responder chain shown in Figure 20.4 ...

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.