How to disable UIAlertAction depending on UITextField in UIAlertController?
问题 I'm using a UIAlertController to present the user with a dialog to enter a 5 digit CRN . I want the Add button to be disabled until there are 5 and only 5 digit in the UITextField . Here's what the UI looks like : Here's the properties setup for the UIAlertController : var alertController: UIAlertController! var addAlertAction: UIAlertAction! { return UIAlertAction(title: "Add", style: .default) } Here's how I'm initializing them in the viewDidLoad method : self.alertController =