---
title: "endMatchInTurn(withMatch:scores:achievements:completionHandler:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gkturnbasedmatch/endmatchinturn(withmatch:scores:achievements:completionhandler:)"
---

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

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

## Declaration

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

```swift
func endMatchInTurn(withMatch matchData: Data, scores: [GKScore]?, achievements: [GKAchievement]?) async throws
```

## 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:

## Discussion

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.

## See Also

### Deprecated Methods

- [participantQuitInTurn(with:nextParticipant:match:completionHandler:)](gamekit/gkturnbasedmatch/participantquitinturn(with:nextparticipant:match:completionhandler:).md)
- [endTurn(withNextParticipant:match:completionHandler:)](gamekit/gkturnbasedmatch/endturn(withnextparticipant:match:completionhandler:).md)
