如何从
swift(iOS)中的特定游戏中心排行榜中获取前10个分数?
我想从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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。