Friday, March 22, 2024

_eventFirstResponderChainDescription

Stephan Casas:

AppKit includes a private category on NSApplication that adds _eventFirstResponderChainDescription — a string describing the current responder chain. This can be a really useful debugging tool!

When your views aren’t handling input events in the way you’d expect, consider dropping this extension into your project to see what’s what[…]

Update (2024-03-25): You can also set the _NS_4445425547 user default to see a Cocoa debug menu. I tend to just leave this enabled in my apps.

Update (2024-04-11): Antoine:

Today’s Darwin crazy hidden debugging tool of the day: iOS has a built in HUD for showing performance statistics like FPS, frame duration etc. […] This HUD can be activated by calling the private CARenderServerSetDebugOption function

See also: Marcin Krzyzanowski.

6 Comments RSS · Twitter · Mastodon

I always pass `-_NS_4445425547 YES` when debugging from Xcode, which gives a nice extra menu item 🐞 with — among other goodies — a window that lists the current responder chain.

Florian, wow, that's great! How did I never know about that?!

It's such a shame tn2124 was killed.

http://web.archive.org/web/20101206131250/http://developer.apple.com/library/mac/#technotes/tn2004/tn2124.html

Nice find. This is a little simpler way to print the value:

print(NSApp.value(forKey: "_eventFirstResponderChainDescription"))

And that _NS_4445425547 thing is really neat!

I wondered if that user default could be injected easily into every app with a “defaults” command, and indeed you can!

defaults write -g _NS_4445425547 -bool true

And in case anyone’s wondering what the 4445425547 means:

0x44 = d
0x45 = e
0x42 = b
0x55 = u
0x47 = g

🤓👍

Fun fact: you can also set

defaults write -g NS🐞 YES

(NS Bug :)

Leave a Comment