title: When/How to use dismissViewControllerAnimated? Does it work with Controller from UIWindow?
body: <p>These questions come from an answer I got from another question <a href="https://stackoverflow.com/questions/24584364/how-to-create-an-alert-in-a-subview-class-in-swift">here</a>.</p>
  
  <p>I wonder does the function calls commented below matter? I tried to run the app and close the alert, but dismissViewControllerAnimated is never being called.</p>
  
  <p>Could someone share some experience on when/how to use such function?</p>
  
  <pre><code>class GameViewController: UIViewController {
      @IBOutlet var gameBoardUIView: GameBoardUIView
      ...
  }
  
  class GameBoardUIView: UIView {
      ...
      func move() {
          if !gameBoard.checkNextMoveExist() {
              let parentViewController: UIViewController = UIApplication.sharedApplication().windows[1].rootViewController
  
              var alert = UIAlertController(title: "Game Over", message: nil, preferredStyle: UIAlertControllerStyle.Alert)
              alert.addAction(UIAlertAction(title: "Take Me Back", style: UIAlertActionStyle.Cancel, handler: {(action: UIAlertAction!) in
                  // parentViewController.dismissViewControllerAnimated(true, completion: nil)
                  println("Taking user back to the game without restarting")
              }))
              alert.addAction(UIAlertAction(title: "New Game", style: UIAlertActionStyle.Destructive, handler: {(action: UIAlertAction!) in
                  // parentViewController.dismissViewControllerAnimated(true, completion: nil)
                  println("Starting a new game")
                  self.restartGame()
              }))
              parentViewController.presentViewController(alert, animated: true, completion: nil)
          }
      }
  }
  </code></pre>
  
  <p>Edit:
  One more specific question to the example I gave above. Why dismissViewControllerAnimated is not doing anything when I click the button on the alert? The messages(e.g. "Starting a new game") are printed successfully. Is it because I get the controller from the UIWindow array?</p>