Hi all,
I have a textfield that I want to limit to letter input only. The code below works for that, but the problem is it also excludes the delete key, which means the user cannot correct any spelling errors. I’m guessing that the delete key is itself a character, but searching has so far proved fruitless. Does anyone know what characterSet the delete key belongs to and/or what it looks like as a character?
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) → Bool {
return string.rangeOfCharacter(from: CharacterSet.letters) != nil
}