title: Swift - How to pass a view controller's reference to a sub UIView class?
body: <p>I have a UIViewController and a UIView inside it. When I try to add an alert inside the UIView, I have to use the controller to present the UIAlertController. How do I pass the reference of UIViewController to the UIView class? Or alternatively how do I create a delegate of controller?</p>
  
  <pre><code>class GameViewController: UIViewController {
      @IBOutlet var gameBoardUIView: GameBoardUIView
      ...
  }
  
  class GameBoardUIView: UIView {
      ...
      func move() {
          if !gameBoard.checkNextMoveExist() {
              var alert = UIAlertController(title: "Game Over", message: nil, preferredStyle: UIAlertControllerStyle.Alert)
              alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Cancel, handler: {(action: UIAlertAction!) in
                  println("Game Over")
              }))
              }))
              // Following would fail because self is not a UIViewController here
              // self.presentViewController(alert, animated: true, completion: nil)
          }
      }
  }
  </code></pre>