I have a textfield that only accepts numbers, however, it does not accept the delete key so I cannot delete anything once it is typed.
I have tried adding NSCharacters, but I cannot seem to figure out the character for the delete key.
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if let x = string.rangeOfCharacter(from: NSCharacterSet.decimalDigits + Character.delete) {
return true
} else {
return false
}
}
It functions correctly, I just can't backspace due to not accepting it in the code.