Created
March 18, 2024 20:35
-
-
Save stephancasas/7580e4970503970390c903ec16edc109 to your computer and use it in GitHub Desktop.
An extension on NSApplication providing a computed property that describes the current responder chain.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSApplication+NSResponderDebug.swift | |
// | |
// Created by Stephan Casas on 3/18/24. | |
// | |
import Cocoa; | |
extension NSApplication { | |
/// Returns a description of the `NSResponder` responder chain starting from the first responder. | |
var responderChainDebugDescription: String { | |
(self as AnyObject).perform( | |
NSSelectorFromString("_eventFirstResponderChainDescription") | |
).takeUnretainedValue() as? String ?? "<Description Unavailable>" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's a little simpler to get the value with key-value coding:
self.value(forKey: "_eventFirstResponderChainDescription") as? String