Swift1 Swift1 - 1 month ago 12x
Swift Question

SpriteKit Game Center Authentication

I am doing a sprite kit Game. I have a problem with Game Center: how i authenticate player?
in AppDelegate.swift i have this code:

func authenticateLocalPlayer()

var localPlayer = getLocalPlayer() // see GKLocalPlayerHack.h
localPlayer.authenticateHandler =
{(viewController : NSViewController?, error : NSError?) -> Void in
if viewController != nil
self.presentViewController(viewController!, animated:true, completion: nil)


but i get this error:

Value of type 'AppDelegate' has no member 'presentViewController'

on this line:

self.presentViewController(viewController!, animated:true, completion: nil)

How can i solve this problem?


I think you need to use something like this. I am not 100% sure what you set for the parentWindow bit, my OSX knowledge is limited.

let dialogController = GKDialogController.shared()
dialogController.parentWindow = yourWindow // not exactly sure what you need to set here

Implementing GameKit.framework on OSX, cannot authenticate localPlayer


Hope this helps.