How can I get a textDidChange method for a UITextField? I need to call a method every time a change is made to a text field. Is this possible? Thanks!
Below is what I used Swift 4
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
guard let fieldText = textField.text else {
return false
}
// Append the existing textfield text with the new character
var text = fieldText + string
// If it is the very first character, textfield text will be empty so take the 'string' and on delete also textfield text get deleted with a delay
if range.location == 0{
text = string
}
return true
}