Swift1 Swift1 - 1 year ago 111
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download