I have a UITextField and am using the delegate method func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool
The fields here have the ability to display suggested text (e.g. name). The problem comes in when a suggestion is taken versus when the user types in single letters. If a suggestion is taken (e.g. Tom) the delegate method fires but string just contains a blank space " ". This causes validation failure since it is assumed the user is typing in an empty space when reality they selected a full word.
How can we use shouldChangeCharactersIn to check text entry but still allow for the use of suggested text?