GKLeaderboardSet Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/GameKit.framework
Availability
Available in iOS 7.0 and later.
Companion guide
Declared in
GKLeaderboardSet.h

Overview

Add leaderboard sets to your app and organize your leaderboards into logical and coherent groups. Once you incorporate leaderboard sets into your app, you must put all of your leaderboards into a set. Individual leaderboards can be put into multiple leaderboard sets and given different display names in each set.

A GKLeaderboardSet object is used to read data from a leaderboard set stored on Game Center. Your game uses GKLeaderboardSet objects when it wants to retrieve localized information about a specific leaderboard set or to retrieve scores from a leaderboard set. Typically, you do this when you want the data needed to implement your own custom leaderboard set user interface.

During the development process, you create the leaderboard sets for your game on iTunes Connect.

To retrieve information about the available leaderboards for the current set, use the loadLeaderboardsWithCompletionHandler: class method.

To retrieve information about the available leaderboard sets, use the loadLeaderboardSetsWithCompletionHandler: class method.

To retrieve information about the image associated with a leaderboard set, use the loadImageWithCompletionHandler: class method.

Tasks

Loading the Leaderboard Sets

Properties

groupIdentifier

Identifies the group that the leaderboard set belongs to. (read-only)

@property(nonatomic, readonly, retain) NSString *groupIdentifier
Discussion

This is set when the leaderboard set is part of a game group. It gets set when loadLeaderboardSetsWithCompletionHandler: is called on leaderboards that support game groups.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKLeaderboardSet.h

identifier

The identifier for the leaderboard set.

@property(copy, nonatomic) NSString *identifier
Availability
  • Available in iOS 7.0 and later.
Declared In
GKLeaderboardSet.h

title

Localized title for the leaderboard set. (read-only)

@property(readonly, copy, nonatomic) NSString *title
Availability
  • Available in iOS 7.0 and later.
Declared In
GKLeaderboardSet.h

Class Methods

loadLeaderboardSetsWithCompletionHandler:

Load all of the leaderboard sets for the current game.

+ (void)loadLeaderboardSetsWithCompletionHandler:(void (^)(NSArray *leaderboardSets, NSError *error))completionHandler
Parameters
completionHandler

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

The block receives the following parameters:

leaderboardSets

An array of GKLeaderboardSet objects that provides the leaderboard sets for 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.

error

If an error occurred, this error object describes the error. If the operation completed successfully, the value 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.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKLeaderboardSet.h

Instance Methods

loadImageWithCompletionHandler:

Load the image associated with the leaderboard set.

- (void)loadImageWithCompletionHandler:(void (^)(UIImage *image, NSError *error))completionHandler
Parameters
completionHandler

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

The block receives the following parameters:

image

The image associated with the leaderboard set. If an error occurred, this value will 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

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.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKLeaderboardSet.h

loadLeaderboardsWithCompletionHandler:

Load all of the leaderboards for the current leaderboard set.

- (void)loadLeaderboardsWithCompletionHandler:(void (^)(NSArray *leaderboards, NSError *error))completionHandler
Parameters
completionHandler

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

The block receives the following parameters:

leaderboards

An array of GKLeaderboard objects that provides the leaderboards for 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.

error

If an error occurred, this error object describes the error. If the operation completed successfully, the value 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.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKLeaderboardSet.h