I want to set focus when form load but it didn't work in awakeFromNib.
[myTextField becomeFirstResponder];
Just to quote the apple docs:
Use the NSWindow makeFirstResponder: method, not this method, to make an object the first responder. Never invoke this method directly.
Do this instead:
[[myTextField window] makeFirstResponder:myTextField];
The Swift version to this question:
textField.window?.makeFirstResponder(textField)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With