在IOS 8中不推荐使用playerID:使用播放器

时间:2015-03-16 16:58:45

标签: ios swift xcode6 game-center

我有这个Game Center功能用于查找玩家。最近我下载了Xcode 6.3 - beta 3。

这是功能:

    func lookupPlayers() {
    let playerIDs = match.players.map { ($0 as! GKPlayer).playerID }

    GKPlayer.loadPlayersForIdentifiers(playerIDs) { (players, error) -> Void in
        if error != nil {
            println("Error retrieving player info: \(error.localizedDescription)")
            self.matchStarted = false
            self.delegate?.matchEnded()
        } else {
            for player in players {
                println("Found player: \(player.alias)")
                self.playersDict[player.playerID] = player //use player
            }

            self.matchStarted = true
            GKMatchmaker.sharedMatchmaker().finishMatchmakingForMatch(self.match)
            self.delegate?.matchStarted()
        }
    }
}

Xcode现在标记了一条警告说"播放器ID在IOS 8中已被弃用:使用播放器"

有人可以帮我修改代码以删除警告。我不明白需要改变什么。

1 个答案:

答案 0 :(得分:3)

尝试这样做,似乎GKPlayer未正确注册

for player in players as! [GKPlayer]
{
    println("Found player: \(player.alias)")
    self.playersDict[player.playerID] = player //use player
}