endMatchInTurn(withMatch:scores:achievements:completionHandler:)
Ends the match while submitting all of the scores and achievements.
Declaration
func endMatchInTurn(withMatch matchData: Data, scores: [GKScore]?, achievements: [GKAchievement]?, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)func endMatchInTurn(withMatch matchData: Data, scores: [GKScore]?, achievements: [GKAchievement]?) async throwsParameters
- matchData:
A serialized blob of data reflecting the current state for the match. Do not pass
nilas an argument. - scores:
An array of
GKScoreobjects containing the final scores for every participant in the match. - achievements:
An array of
GKAchievementobjects containing the achievements acquired by each participant in the match. - completionHandler:
A block to be called after the scores are saved to the server.
The block receives the following parameters:
- error
If an error occurred, this error object describes the error. If the operation was 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.
This method ends the current match and submits scores and achievements for all of the participants. The scores can submitted to multiple leaderboards. The GKTurnBasedMatchOutcome status must be set for each participant before calling this method.