Instance Method

setDefaultLeaderboardCategoryID(_:completionHandler:)

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

Declaration

func setDefaultLeaderboardCategoryID(_ categoryID: String?, completionHandler: ((Error?) -> Void)? = nil)

Parameters

categoryID

The category ID string for one of your game’s leaderboards.

completionHandler

A block to be called when the request completes.

The block receives the following parameter:

error

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

Discussion

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.

The default leaderboard is configured in App Store Connect as part of configuring your game’s leaderboards. All players normally start with this leaderboard as the default leaderboard. Calling this method changes the default leaderboard only for the local player.

See Also

Deprecated Methods and Properties

func authenticate(completionHandler: ((Error?) -> Void)?)

Authenticates the local player on the device.

Deprecated
var friends: [String]?

An array of NSString objects containing the player identifiers for the local player’s friends.

Deprecated
func loadDefaultLeaderboardCategoryID(completionHandler: ((String?, Error?) -> Void)?)

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

Deprecated
func loadFriendPlayers(completionHandler: (([GKPlayer]?, Error?) -> Void)?)

Retrieves a list of player identifiers for the local player’s friends.

Deprecated
func loadFriends(completionHandler: (([String]?, Error?) -> Void)?)

Retrieves a list of player identifiers for the local player’s friends.

Deprecated