I'm trying to put cursor in first UITextField inside UITableView and let keyboard to be displayed as wrote like that.
if (indexPath.row == 0) {
cell.inputTextField.becomeFirstResponder()
}
But warning showing like that.
Result of call to 'becomeFirstResponder()' is unused
How to put cursor in first UITextField and let KeyBoard to be displayed?
I meet it when override 'becomeFirstResponder',if you want remove it,you can use @discardableResult
Since becomeFirstResponder()
returns a Bool, you are supposed to check the return value according to warning.
If you don't need to know becomeFirstResponder
was successful, you should write:
let _ = cell.inputTextField.becomeFirstResponder()
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