The Responder Chain

March 23rd, 2007

Looks like I’m about a week behind in my Late Night Cocoa listening. I finally caught up with the episode on NSResponder, featuring Aaron Hillegass of Big Nerd Ranch.

Scotty is doing such a fantastic job with all the podcasts, I shouldn’t be surprised that this one was also excellent. I really like the way he pulls information out of his guests in a way that makes the shows engaging for both experienced and (I assume!) newbie Cocoa developers alike.

This episode in particular is a must-listen for Cocoa developers who aren’t completely comfortable with the responder chain. In particular, I like the way Aaron comes right out and declares the "First Responder" proxy icon in Interface Builder to be "a lie." In my travels I’ve found that "First Responder" is a woefully misunderstand concept.

Mostly the material in the show was a recap for me, but one concept I had never considered was that of a "view controller" that is inserted directly into the responder chain. Whoah, nifty! Aaron referred specifically to the MOViewController from the MOKit open source framework, by Mike Ferris. The idea is instead of subclassing a view to be able to get at all of its NSResponder-oriented behaviors, why not just insert an object immediately before it in the chain? Now you can respond to whatever want to (Aaron uses the example of a delete key for NSTableView), and pass the rest of the events through to the view.

Great stuff. Thanks Scotty & Aaron for an entertaining and educational show.

5 Responses to “The Responder Chain”

  1. patrick Says:

    The view controllers from MOKit seem to be intended to be ‘behind’ the view, not in front of it. So it would be between the view and its super view in the responder chain. (getting it in front of the view would be more difficult?)

  2. Daniel Jalkut Says:

    Good point, Patrick. I wasn’t thinking straight. You’re right, it would be difficult because to get in front of it you’d essentially have to become first responder, or the parent of some first responder.

  3. Scott Stevenson Says:

    Your episode of Late Night Cocoa was the first time I was really exposed to the basic mechanisms of AppleScript it Cocoa. Thanks for taking the time to talk about it.

  4. Daniel Jalkut Says:

    Scott: Great! I’m glad you got something out of it.

  5. Mike Ferris Says:

    Credit where credit is due… MOViewController is a reimplementation of a concept from XCode (then ProjectBuilder) that was originally written by my colleague Anders and which was refined by both of us in that context. In particular, making the view controller be a responder and inserting it into the responder chain between its view and its view’s superview was in Anders’ original implementation. MOKit’s version is distinct but owes a lot of its design to that original.

Comments are Closed.

Follow the Conversation

Stay up-to-date by subscribing to the Comments RSS Feed for this entry.