0

There is a method in UITextFieldDelegate

textField(_:shouldChangeCharactersInRange:replacementString:)

Which allows me to do it. But I want custom text field handle this automatically to update its state without delegate and I don't want to use delegate internally as it can be overridden. How should I do this?

For example there is a method - becomeFirstResponder which I override to show/hide validation error when text field resigns from being first responder, but there seems to be nothing for handling text property changes, or was I inattentive?

Sahil
  • 9,096
  • 3
  • 25
  • 29
mra214
  • 509
  • 1
  • 7
  • 18

1 Answers1

4

You could use UITextFieldTextDidChangeNotification.

Or you could subclass so you can be your own delegate and also forward delegate calls to another delegate which is added (so your internal delegate is a proxy for the real delegate, handling the call and then forwarding it).

Wain
  • 118,658
  • 15
  • 128
  • 151