This the code block I'm having trouble with.It gives me error because of 'presentViewController'
func authenticateLocalPlayer(){
let localPlayer = GKLocalPlayer.localPlayer()
localPlayer.authenticateHandler = {(viewController, error) -> Void in
if (viewController != nil) {
self.presentViewController(viewController!, animated: true, completion: nil)
}
else {
print((GKLocalPlayer.localPlayer().authenticated))
}
}
}
I know it's because SKScene has already has a UIViewController, but I don't know how else to represent it.
You can't call presentViewController
from within your SKScene
, you need to call it on a UIViewController
.
Therefore you want to find the parent view controller that contains your Sprite Kit content and call the function there.