An object containing information for a score that was earned by the player.
SDKs
- iOS 4.1+
- macOS 10.8+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 3.0+
Framework
- Game
Kit
Declaration
@interface GKScore : NSObject
Overview
Important
Your game must authenticate a local player before you can use any Game Center classes. If there is no authenticated player, your game receives a GKError
error. For more information on authentication, see Game Center Programming Guide.
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 report
method. The mechanism your game uses to calculate scores is up to you to design; scores are only compared within your game.