Reports a list of scores to Game Center
- iOS 6.0+
- macOS 10.8+
- tvOS 9.0+
- watchOS 3.0+
An array of
GKScoreobjects that contains the scores to report to Game Center.
A block to be called after the score is reported.
The block receives the following parameter:
If an error occurred, this parameter holds an error object that describes the problem. If the score was successfully reported, this parameter’s value is
Use this class method whenever you need to submit scores to Game Center, whether you are reporting a single score or multiple scores. The method runs through the array of
GKScore objects, submitting scores one at a time.
report(_: provides a sample method to report a score. The
GKScore object is initialized with the leaderboard ID for the leaderboard it reports its score to and then the
context for the score are assigned. The leaderboard ID must be the identifier for a leaderboard you configured in App Store Connect. Scores are always reported for the current local player and never for friends.
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, GameKit calls your completion handler. The completion handler is always called on the main thread.