UITextField Value Changed Event?

iphone, uitextfield

Solution

Objective-C

[myTextField addTarget:self 
                action:@selector(textFieldDidChange:) 
      forControlEvents:UIControlEventEditingChanged];

Swift 4

myTextField.addTarget(self, action: #selector(textFieldDidChange(sender:)), for: .editingChanged)

@objc func textFieldDidChange(sender: UITextField) {...}

Problem

How can I make it so that when the contents of a text field changes, a function is called?

Original source