Tuesday, July 30, 2019

Debugging the Responder Chain

Jeff Nadeau:

Maybe this will make it easier to see what’s up w/ the responder chain. Pause in the debugger and run

(lldb) e -- (void)[[[NSClassFromString(@"NSDebugMenuResponderChainProvider") alloc] init] toggleResponderChainPanel:nil]

and then continue. (I reserve the right to break this.)

Andy Lee:

I usually add my own method to the app delegate that prints the responder chain, starting with the current first responder. Often I add a temporary menu item that calls that method, and assign it a keyboard shortcut.

And here’s a link to the responder chain documentation, since it’s now in the archive and not easy to find simply by following links. (You’d think it would be linked from the NSResponder page).

Update (2019-08-01): Friedrich Markgraf:

If you need to figure out on which instance in the responder chain an action method (like scrollWheel:) is actually called, you can use a logging symbolic breakpoint like this[…]

Comments RSS · Twitter

Leave a Comment