How do I find out which object is first responder?

How do I find out which object is first responder? Surely there is a property of some object that holds a reference to the first responder.

Accepted Reply

It depends on where the user is in the app's flow. In iOS there is no simple call to retrieve the current first responder (without private APIs) - see this dated SO thread for discussion: https://stackoverflow.com/questions/5029267/is-there-any-way-of-asking-an-ios-view-which-of-its-children-has-first-responder

Docs says this about that, otherwise:

"The first responder is typically the view in a window that an app deems best suited for handling an event."


https://developer.apple.com/library/content/documentation/General/Conceptual/Devpedia-CocoaApp/Responder.html


Why do you need this?

Replies

It depends on where the user is in the app's flow. In iOS there is no simple call to retrieve the current first responder (without private APIs) - see this dated SO thread for discussion: https://stackoverflow.com/questions/5029267/is-there-any-way-of-asking-an-ios-view-which-of-its-children-has-first-responder

Docs says this about that, otherwise:

"The first responder is typically the view in a window that an app deems best suited for handling an event."


https://developer.apple.com/library/content/documentation/General/Conceptual/Devpedia-CocoaApp/Responder.html


Why do you need this?