title: Get notified when UIAlertController is being dismissed on button press
body: <p>I would like to do some actions and present some UI right before and right after any UIAlertController dismisses itself (animation is finished) due to user tapping one of the alert's buttons.</p>
  
  <p>How can I get notified that user pressed some button in my UIAlertController and it is going to be dismissed and then is dismissed?</p>
  
  <p>In docs it is advised against subclassing UIAlertController. I still have tried my luck subclassing, thinking that maybe it internally calls <code>func dismiss(animated flag: Bool, completion: (() -&gt; Void)? = nil)</code> on itself. Something like <code>self.dismiss(...</code>, but it doesn't seem to be the case on iOS10.</p>
  
  <p>I have also tried to add 'manual' dismissing into UIAlertAction handler:</p>
  
  <pre><code>let alert = UIAlertController.init(...
  let defaultAction = UIAlertAction(title: "OK", style: .default, handler: { action in
      alert.dismiss(animated: true, completion: { 
          print("Dismissed")
      })
  })
  alert.addAction(defaultAction)
  </code></pre>
  
  <p>But it seems that alert is dismissed after button press but before calling handler. Anyhow it doesn't work as well. Even if it worked it would be a bit bothersome to remember to add my code into each and every UIAlertAction handler.</p>
  
  <p>I would appreciate any ideas.</p>