<!--
{
  "availability" : [
    "iOS: 6.0.0 - 14.0.0",
    "iPadOS: 6.0.0 - 14.0.0",
    "macCatalyst: 13.1.0 - 14.0.0",
    "macOS: 10.10.0 - 11.0.0",
    "tvOS: 9.0.0 - 14.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 3.0.0 - 7.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKTurnBasedMatch/endMatchInTurn(withMatch:scores:achievements:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKTurnBasedMatch(im)endMatchInTurnWithMatchData:scores:achievements:completionHandler:"
  },
  "title" : "endMatchInTurn(withMatch:scores:achievements:completionHandler:)"
}
-->

# endMatchInTurn(withMatch:scores:achievements:completionHandler:)

Ends the match while submitting all of the scores and achievements.

```
func endMatchInTurn(withMatch matchData: Data, scores: [GKScore]?, achievements: [GKAchievement]?, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

## Parameters

`matchData`

A serialized blob of data reflecting the current state for the match. Do not pass `nil` as an argument.

`scores`

An array of `GKScore` objects containing the final scores for every participant in the match.

`achievements`

An array of `GKAchievement` objects 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)