Search code examples
swiftgamekit

How do I make the default value 0 with GameKit


let localPlayerScore = request.localPlayerScore ?? 0

The problem is that Swift is expecting the 0 to be of type GKScore.

I get the following error:

Cannot convert value of type 'Int' to expected argument type 'GKScore'


Solution

  • let localPlayerScore = request.localPlayerScore.value ?? 0

    GKScore