Class

GKScore

An object containing information for a score that was earned by the player.

Declaration

@interface GKScore : NSObject

Overview

Your game creates GKScore objects to post scores to a leaderboard on Game Center. When your game retrieves score information from a leaderboard, those scores are returned as GKScore objects.

Scores and leaderboards work together to help you create a better game. Whenever a new GKScore object is created, it is associated with a leaderboard. You must ensure that the score being sent to a leaderboard is compatible with the leaderboard scoring format set in App Store Connect. See Leaderboards and Leaderboard Sets for information on how to create a leaderboard in App Store Connect.

To report a score to Game Center, your game allocates and initializes a new object, sets the value property to the score the player earned, and then calls the reportScoreWithCompletionHandler: method. The mechanism your game uses to calculate scores is up to you to design; scores are only compared within your game.

Topics

Initializing a Score

- initWithLeaderboardIdentifier:

Returns an initialized score object using the local player and the current date.

- initWithLeaderboardIdentifier:player:

Returns an initialized score object for the specified leaderboard and player.

Score Properties

context

An integer value used by your game.

date

The date and time when the score was earned.

formattedValue

Returns the player’s score as a localized string.

leaderboardIdentifier

The identifier for the leaderboard.

player

The player identifier for the player that earned the score.

rank

The position of the score in the results of a leaderboard search.

value

The score earned by the player.

Reporting a New Score

+ reportScores:withCompletionHandler:

Reports a list of scores to Game Center

+ reportScores:withEligibleChallenges:withCompletionHandler:

Submit a list of scores and all eligible challenges.

Changing the Default Leaderboard

shouldSetDefaultLeaderboard

A Boolean value that indicates whether this score should also update the default leaderboard.

Issuing a Score Challenge

- challengeComposeControllerWithMessage:players:completionHandler:

Provides a challenge compose view controller with pre-selected player identifiers and a preformatted, player-editable message.

Deprecated Methods and Properties

category

The leaderboard that this score belongs to.

Deprecated
- challengeComposeControllerWithPlayers:message:completionHandler:

Provides a challenge compose view controller with pre-selected player identifiers and a preformatted, player-editable message.

Deprecated
- initWithCategory:

Returns an initialized score object.

Deprecated
- initWithLeaderboardIdentifier:forPlayer:

Returns an initialized score object for the specified leaderboard and player.

Deprecated
- issueChallengeToPlayers:message:

Issues a score challenge to a set of players.

Deprecated
playerID

The player identifier for the player that earned the score.

Deprecated
- reportScoreWithCompletionHandler:

Reports a score to Game Center.

Deprecated

Relationships

Inherits From

See Also

Leaderboards

GKLeaderboard

An object used to read data from a leaderboard stored on Game Center.

GKLeaderboardSet

An object that organizes leaderboards into logical and coherent groups.