How to check which TextField is FirstResponder from another ViewController?

642 views Asked by At

I'm using Swift 4 on macOS. I know that I can set the becomeFirstResponder() to a TextField like this:

mytextfield.becomeFirstResponder()

But how can I check if mytextfield is FirstResponder?

1

There are 1 answers

0
Lucas Derraugh On BEST ANSWER

Your assumption is wrong about -becomeFirstResponder. From the documentation:

Notifies the receiver that it’s about to become first responder in its NSWindow.

You make something first responder through NSWindow's -makeFirstResponder:.

To answer your question, the property is on NSWindow as well called firstResponder.