The GKLeaderboardViewController class provides a standard user interface that displays leaderboard scores to the player. If the GKGameCenterViewController class is available, you should use it instead.


class GKLeaderboardViewController : GKGameCenterViewController


To show a leaderboard screen, initialize a new GKLeaderboardViewController object and set the delegate. Optionally, you can configure the view controller to display specific data to the player. Then, present the new view controller and wait for the delegate to be called. Once the delegate is called, dismiss the view controller.

On iOS, you present and dismiss the view controller from another view controller in your game, using the methods provided by the UIViewController class. In macOS, you use the GKDialogController class to present and dismiss the view controller.

Your game should pause other activities before presenting the leaderboard.

Subclassing Notes

The GKLeaderboardViewController class is not intended to be subclassed.


Configuring the Leaderboard View Controller

var category: String!

The named leaderboard that is displayed by the view controller.

var timeScope: GKLeaderboard.TimeScope

A time filter used to restrict which scores are displayed to the player.

See Also

Leaderboard View Controllers

protocol GKLeaderboardViewControllerDelegate

The GKLeaderboardViewControllerDelegate protocol is implemented by delegates of the GKLeaderboardViewController class. The delegate is called when the player dismisses the leaderboard.