How do I validate TextFields in an UIAlertController?
问题 Can anyone tell me how to validate UITextFields inside of a UIAlertController ? I need it to prevent the user from clicking "Save" unless both fields are entered. Here is my code so far: @IBAction func btnStart(sender: AnyObject) { var alert = UIAlertController(title: "New user", message: "Add a new user", preferredStyle: .Alert) let saveAction = UIAlertAction(title: "Save", style: .Default) { (action: UIAlertAction!) -> Void in self.textFieldName = alert.textFields![0] as UITextField self