UITextViewDelegate has a very useful method: -textViewDidChange:. As the name implies, text view calls this method on its delegate whenever the text it is currently presenting is changed.

But, unlike UITextViewDelegate, UITextFieldDelegate doesn’t have such a method. Instead, it has a hidden gem that provides the same functionality.


Meet our hero! You can either assign an IBAction for this event in Interface Builder or add a target and action in code.


- (IBAction)textFieldDidChangeText:(UITextField *)textField {
    NSLog(@"Updated text: %@", textField.text);

This way, whenever a change appears on text field, it will call the action method assigned for UIControlEventEditingChanged event.