Instance Method


Loads the category identifier for the local player’s default leaderboard.


func loadDefaultLeaderboardIdentifier(completionHandler: ((String?, Error?) -> Void)? = nil)



A block to be called when the request completes.

The block receives the following parameters:


The category ID string for the local player’s default leaderboard.


If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.


This method loads the default leaderboard set in App Store Connect. Use this method to retrieve the default leaderboard.

Listing 1

Loading the default leaderboard for the local player

[[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:
(void(^)(NSString *leaderboardIdentifier, NSError *error)) {
    if (error != nil) {
        NSLog(@"Failed to load default leaderboard with value of '%@' because of error: %@", leaderboardIdentifier, error)
    else {
        NSLog(@"Successfully loaded the default leaderboard")

When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. The completion handler is always called on the main thread.

See Also

Working with Leaderboards