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

# endMatchInTurn(withMatch:completionHandler:)

Ends the match.

```
func endMatchInTurn(withMatch matchData: Data, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

## Parameters

`matchData`

Your game-specific data representing the match state. For example, include information needed for the next participant to take their turn in this object. Don’t pass `nil` as this parameter.

`completionHandler`

The block that GameKit calls when it completes the request.

    The block receives the following parameter:

- *error*: Describes an error if it occurs, or `nil` if the operation completes.

## Discussion

Invoke this method only when the local player is the current participant. Also, set the [`matchOutcome`](/documentation/GameKit/GKTurnBasedParticipant/matchOutcome) property for each participant in the match’s [`participants`](/documentation/GameKit/GKTurnBasedMatch/participants) property to a value other than [`GKTurnBasedMatch.Outcome.none`](/documentation/GameKit/GKTurnBasedMatch/Outcome/none) before invoking this method.

To receive turn-based events that this method generates, register a listener that conforms to the [`GKTurnBasedEventListener`](/documentation/GameKit/GKTurnBasedEventListener) protocol with the local player. See [Starting turn-based matches and passing turns between players](/documentation/GameKit/starting-turn-based-matches-and-passing-turns-between-players).

---

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)