I'm having problems with the below code storing the right characters from user: If the user enters "there" it stores "ther".
func textField(_ textField: UITextField,
shouldChangeCharactersIn range: NSRange,
replacementString string: String)
-> Bool
{
let text: String = nameInputText.text!
//print(text) //this prints My text
model.validateName(nametext: text)
print(text)
return true
}
I also have these functions for my keyboard hiding:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
nameInputText.resignFirstResponder()
return (true)
}