Avatar ·

How to track text changes in UITextField in Swift?

Hello! I'm new to iOS development in Swift and ran into a problem. I need to perform some action every time the text in UITextField changes — for example, update the interface or validate input. But I can't figure out how to do it correctly. Here's my code. I have a text field and a button. I want the button to automatically become enabled (if the text is not empty) or disabled (if the field is empty) when text is entered. I tried using the UITextFieldDelegate with the textFieldDidChangeSelection method, but it doesn't work as I expected. Maybe I'm doing something wrong? Here's my code: ```swift class ViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var textField: UITextField! @IBOutlet weak var submitButton: UIButt ```