Avatar ·

How to track text change in UITextField in Swift? Text change event

Hi! I'm a beginner in iOS development with Swift and I've run into a problem. I need to track in real-time when a user enters or deletes text in UITextField and perform some action (e.g., check the length of the entered text or update the interface). I tried using the UITextFieldDelegate and the textFieldDidChangeSelection method, but it doesn't get called when I just type. Here's my code: ```swift class ViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var myTextField: UITextField! override func viewDidLoad() { super.viewDidLoad() myTextField.delegate = self } func textFieldDidChangeSelection(_ textField: UITextField) { print("Text changed: \(textField.text ?? "")") } } ```