title: How to call a function in viewController from GameScene
body: <p>I am wanting to call a share function during game play. I have some code I can use in my GameViewController</p>
  
  <pre><code>func showTweetSheet() {
      let tweetSheet = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
      tweetSheet.completionHandler = {
          result in
          switch result {
          case SLComposeViewControllerResult.Cancelled:
              //Add code to deal with it being cancelled
              break
  
          case SLComposeViewControllerResult.Done:
              //Add code here to deal with it being completed
              //Remember that dimissing the view is done for you, and sending the tweet to social media is automatic too. You could use this to give in game rewards?
              break
          }
      }
  
      tweetSheet.setInitialText("Test Twitter") //The default text in the tweet
      tweetSheet.addImage(UIImage(named: "TestImage.png")) //Add an image if you like?
      tweetSheet.addURL(NSURL(string: "http://twitter.com")) //A url which takes you into safari if tapped on
  
      self.presentViewController(tweetSheet, animated: false, completion: {
          //Optional completion statement
      })
  }
  </code></pre>
  
  <p>I have also set the ViewController in my GameScene Class...</p>
  
  <pre><code>var viewController: GameViewController!
  </code></pre>
  
  <p>... and set the scene.viewController to self in my ViewController</p>
  
  <pre><code>class GameViewController: UIViewController {
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
          // Configure the view.
          let skView = self.view as! SKView
          skView.showsFPS = false
          skView.showsNodeCount = false
  
          /* Sprite Kit applies additional optimizations to improve rendering performance */
          skView.ignoresSiblingOrder = true
  
          /* Set the scale mode to scale to fit the window */
          scene.scaleMode = .AspectFill
  
          skView.presentScene(scene)
  
          scene.viewController? = self
  
      }
  }
  </code></pre>
  
  <p>However, When I call the function like so...</p>
  
  <pre><code>viewController.showTweetSheet()
  </code></pre>
  
  <p>... from my GameScene it gives me a "found nil when unwrapping an optional value" error.</p>
  
  <p>I think I may need to set the scene.viewController to self later on, but I don't know how to do that in the viewController.</p>
  
  <p>Any help would be much appreciated.</p>