如何从 swift(iOS)中的特定游戏中心排行榜中获取前10个分数? 我想从leaderbaord获得前10名的得分和球员,并在比赛中建立一个自定义的“HALL OF FAMES”. 如何从leaderbaord获取数据? 同时我找到
我想从leaderbaord获得前10名的得分和球员,并在比赛中建立一个自定义的“HALL OF FAMES”.
如何从leaderbaord获取数据?
let leaderBoardRequest = GKLeaderboard() leaderBoardRequest.identifier = kGcIdHighScore // my GC Leaderboard ID leaderBoardRequest.playerScope = GKLeaderboardPlayerScope.Global leaderBoardRequest.timeScope = GKLeaderboardTimeScope.AllTime leaderBoardRequest.range = NSMakeRange(1,10) // top 10 leaderBoardRequest.loadScoresWithCompletionHandler { (scores, error) -> Void in if (error != nil) { print("Error: \(error!.localizedDescription)") } else if (scores != nil) { print("got top \(scores?.count) scores" ) var ii = 0 while (ii < scores?.count) { NSLog("%i ....... %@ %i %i", Int(ii+1), scores![ii].player.alias! , scores![ii].rank , scores![ii].value ) ii = ii + 1 } } } // end leaderBoardRequest.loadScoresWithCompletionHandler