GKLeaderboardViewController Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/GameKit.framework
Availability
Available in OS X v10.8 and later.
Companion guide
Declared in
GKLeaderboardViewController.h

Overview

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.

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. On OS X, 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.

Tasks

Configuring the Leaderboard View Controller

Properties

category

The named leaderboard that is displayed by the view controller.

@property(nonatomic, retain) NSString *category
Discussion

The category property must either be nil or it must match a leaderboard identifier for a leaderboard you defined in iTunes Connect. If nil, the view displays scores for the default leaderboard. Default is nil.

When the view controller is presented, the initial leaderboard shown is based on the value of this property. If the player changes which leaderboard they are viewing, the category property is automatically updated. For example, you can read the category property after the screen is dismissed, and set that value the next time you initialize a new leaderboard view controller.

Availability
  • Available in OS X v10.8 and later.
Declared In
GKLeaderboardViewController.h

leaderboardDelegate

The view controller’s delegate.

@property(nonatomic, assign) id<GKLeaderboardViewControllerDelegate> leaderboardDelegate
Discussion

Before displaying the leaderboard, you must set a delegate.

Availability
  • Available in OS X v10.8 and later.
Declared In
GKLeaderboardViewController.h

timeScope

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

@property(nonatomic, assign) GKLeaderboardTimeScope timeScope
Discussion

This property determines which tab view is displayed to the player. The default value is GKLeaderboardTimeScopeAllTime, which shows the best score each player has earned. For more information on time scopes, see GKLeaderboard Class Reference.

If the player changes which tab they view, the timeScope property is automatically updated. For example, you can read the timeScope property after the view controller is dismissed, and set that value the next time you initialize a new leaderboard view controller.

Availability
  • Available in OS X v10.8 and later.
Declared In
GKLeaderboardViewController.h