Hi everybody.
Between Swift 1.2 and Swift 2.0, the GKPlayer class change the way some properties can return nil.
I can get it for the alias (even if I'm not sure you can setup a Game Center account without entering a nickname), but I really can't get it for these properties :
- playerID :
How a player can't have a player ID ??
- displayName :
You always need something to display. Apple does, right ?
- guestIdentifier:
It's mandatory to provide a guestIdentifier when you create a guest with anonymousGuestPlayerWithIdentifier. How the value can be nil in return?
If you have some clue about how these properties can return nil, thanks in advance for sharing it. I just want to know how to manage these case in my code 😉
Have a great coding day!
Alexis.
From a Swift perspective, these methods can potentilly return nil because that's how they were declared (as nullable) in the obj-c header.
To get an answer about why they were declared that way, you will probably need to get the attention of an Apple engineer that works on GameKit.
The Game Center section is probably a better bet https://forums.developer.apple.com/community/graphics-and-games/game-center,
or file a bug report about GameKit requesting that the GKPlayer nullability annotations be fixed or the methods be properly documented to explain in what circumstances they might return nil.