I'm trying to make a code verification screen. You probably saw it in every app, that requires phone or SMS verification.
The main concern for me is how to set limited available characters for the user to type in the text field.
I'm using reactive Swift, and here is what I came to:
- Created an observable variable in my view
- The presenter is responsible for checking some symbols; a user gave typed. When this type is becoming equal to 10 (for instance) observable variable receives false signal
Delegate method is listening to an observable variable. It is working, but when I reach ten symbols, I can't delete anything. So, my return button on keyboard becomes disabled.
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { return isButtonHidden.value }
However, I still think it is not the "best practice". What can you recommend in that case?