2

How can I call my showLeader() function from GameViewController.swift in GameScene.swift ? this is my showLeader function

func showLeader() {
    var vc = self.view?.window?.rootViewController
    var gc = GKGameCenterViewController()
    gc.gameCenterDelegate = self
    vc?.presentViewController(gc, animated: true, completion: nil)
}
Halvor Holsten Strand
  • 19,829
  • 17
  • 83
  • 99
wanksta11
  • 59
  • 4
  • 9

1 Answers1

1

You make use of NSNotificationCenter to present the viewController from an SKScene. Remember to add the observer and then post the notification. Don't forget to deinit the NSNotification when you no longer need it or your app will crash.

Wraithseeker
  • 1,884
  • 2
  • 19
  • 34