Type Method

loadCategories(completionHandler:)

Loads the list of leaderboard categories along with their corresponding localized titles.

Declaration

class func loadCategories(completionHandler: (([String]?, [String]?, Error?) -> Void)? = nil)

Parameters

completionHandler

A block that is called when the categories have been retrieved from the server.

The block receives the following parameters:

categories

An array of NSString objects that provides the categories to your game. If an error occurred, this value may be non-nil. In this case, the array holds whatever data Game Kit was able to download before the error occurred.

titles

An array of NSString objects that provides localized titles for each category. If an error occurred, this value may be non-nil. In this case, the array holds whatever data Game Kit was able to download before the error occurred.

error

If an error occurred, this error object describes the error. If the operation completed successfully, the value is nil.

Discussion

You use this class method to retrieve the category identifiers and titles you configured for your leaderboards in App Store Connect. To create a leaderboard query that targets a particular category, set the category property to one of the strings returned by this method.

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

Deprecated Methods and Properties

var category: String?

The named leaderboard to retrieve information from.

Deprecated
class func setDefault(String?, withCompletionHandler: ((Error?) -> Void)?)

Sets the default leaderboard for the local player.

Deprecated
init?(playerIDs: [String]?)

Initializes a leaderboard request to retrieve the scores of a specific group of players.

Deprecated