I'm trying to start a new GKGameSession and when I use createSession, all I can get so far is nil. Here's my code:
GKGameSession.createSession(inContainer: "test", withTitle: "MyGame", maxConnectedPlayers: 8)
{ (newGameSession, error) in
self.gameSession = newGameSession
print("\(newGameSession)")
newGameSession?.getShareURL(completionHandler: { (url, error) in
print("url: \(url) error: \(error)")
})
}
The only thing it prints is "nil". Any help is appreciated.
newGameSessionis optional. So it seems like something has gone wrong when creating a new session.I would say
newGameSessionis likelynil, in that caseerrorwill hopefully contain some useful information.Try replacing
print("\(newGameSession)")withprint(newGameSession, error)to see what theerrorvar has to say, or set a breakpoint if you know how to do that.