Execute text field after each letter

Hi there

I want the text field to always trigger an action when you enter a new number or delete it again. After each number, the text field should execute the action again.

Greetings Neo

Create an IBAction


    @IBAction func textChanged(_ sender: UITextField) {
    
        // Do what you need here
        print("text Changed to", sender.text!)          // Just for illustration
    }


Open the Connections Inspector for the tetField

and connect TextField sentEvent: Editing Changed to the IBAction.


That's it.


Ask if you have further question. Otherwise, thanks to mark the thread as closed.

You might want to look at the Apple documentation on Key Events to get a general overview of how key events and keyboard processing works. You also need to look at NSResponder keyDown and keyUp methods. A text field is derived from a view which is derived from NSResponder, so, you will override those methods to handle your custom textfield processing.

Execute text field after each letter
 
 
Q