Retrieves a set of scores from Game Center.
- iOS 4.0+
- macOS 10.8+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 3.0+
A block to be called after the scores are retrieved from the server.
The block receives the following parameters:
An array of
GKScoreobjects that holds the requested scores. If an error occurred, this value may be non-
nil. In this case, the array holds whatever score data could be retrieved from Game Center before the error occurred.
If an error occurred, this error object describes the error. If the operation was completed successfully, the value is
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.
Listing 1 shows an example leaderboard data query. The method for this query initializes a new leaderboard object and configures the
range properties to grab the top ten scores earned today.
You can create a leaderboard request that retrieves scores for a specific list of players you are interested in.
You can call this method multiple times; each call represents a different query against the scores stored on Game Center. If you post multiple load operations using the same leaderboard object, any properties that are updated by loading scores reflect the last query that completed. The order that achievement queries are processed is arbitrary.