从 GKCloudPlayer.playerID 获得 GKPlayer.playerID

Get GKPlayer.playerID from GKCloudPlayer.playerID

我想在我的 iOS 10 多人游戏中使用新的 class GKGameSession。我需要从 Game Center 获取所有用户的 playerID 以检查与我的游戏以前版本的兼容性。但是 GKPlayer.playerID != GKCloudPlayer.playerID

如何从 GKCloudPlayer.playerID 得到 GKPlayer.playerID

你不应该这样做。他们在上届 WWDC 中提到了这一点。

GKCloudPlayer is only for, to be used for Sessions. It basically has two pieces of data, a player ID that is unique to your app as well as the display name, that is what the user will have as what they want they name to be displayed. This is not a GKPlayer object at all.

If you try to use this for a leaderboard, for achievements, for other multiplayer, for anything else, it will not work. So please don't do that.

Everyone will be very disappointed. So how do we get our Cloud Players? Basically you can get your current signed in player.

Most of the things in Sessions basically are going to be called from your current player though there's not a whole lot of need to make sure that you have the player, that you are then saying, "Oh, this player is saving this data." All that's handled for you in the background.

https://developer.apple.com/videos/play/wwdc2016-611/?time=1139