GameCenterManager
GameCenterManager copied to clipboard
Request GKScore
Hi i create this function for request GKScore can you implement that ? it is swift if you want convert it tell me .
func requestLeaderboard(#leaderboardIdentifier:String,completion: ((result:GKScore?) -> Void)) {
if GameCenterManager.sharedManager().isGameCenterAvailable {
let leaderBoardRequest = GKLeaderboard()
leaderBoardRequest.identifier = leaderboardIdentifier
leaderBoardRequest.loadScoresWithCompletionHandler { (scores, error) ->
Void in
if error != nil {
println("Error: \(error!.localizedDescription)")
completion(result: nil)
} else if (scores != nil) {
completion(result: leaderBoardRequest.localPlayerScore)
}
}
}
}
it is with callback
I have again that /** Show banner game center
:param: title title
:param: description description
:param: completion if show message is showing
*/
class func showBannerWithTitle(#title:String, description:String,completion: ((isShow:Bool) -> Void)?) {
GKNotificationBanner.showBannerWithTitle(title, message: description, completionHandler: { () -> Void in
if completion != nil { completion!(isShow:true) }
})
}
in - (void)syncGameCenter
you have
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] initWithPlayerIDs:[NSArray arrayWithObject:[self localPlayerId]]];
it is deprecated
For Ios8 you have that GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] initWithPlayers:[NSArray arrayWithObject:[self localPlayerId]]];