title: UIAlertController with textfield: how dismiss keyboard works?
body: <p>In my <code>UIViewController</code> subclass I created a <code>UIAlertController</code> with a <code>UITextField</code>:</p>
  
  <pre><code>class MyViewController: UIViewController {
  ...
  
       let alertController = UIAlertController(title: "a title", message: "", preferredStyle: .alert)
       let okAction = UIAlertAction(title: "OK!", style: .default) { alert in
            print("OK!!")
       }
       alertController.addTextField { (textField) in
       textField.placeholder = "a placeholder"
       textField.delegate = self
       }
       alertController.addAction(okAction)
       self.present(alertController, animated: true, completion: nil)
  
  ...
  
  }
  
  extension MyViewController: UITextFieldDelegate {
        func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
            return true
        }
  }
  </code></pre>
  
  <p>Now, when alert is shown and I tap keyboard next/done button, the keyboard and the alert are dismissed and <em>OK!</em> is printed.</p>
  
  <p>In my <code>textFieldShouldReturn</code> method there are neither <code>textField.resignFirstResponder()</code> nor alert dismiss command, so how it's possible that keyboard and alert is dismissed? How Apple achieves this behaviour? Has <code>textField</code> two delegates?</p>