<!--
{
  "availability" : [
    "iOS: 4.1.0 -",
    "iPadOS: 4.1.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKMatch",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKMatch"
  },
  "title" : "GKMatch"
}
-->

# GKMatch

A peer-to-peer network between a group of players that sign into Game Center.

```
class GKMatch
```

## Overview

Matches provide a mechanism for a player to send both game and voice data to other players.

You never create a `GKMatch` object directly. Instead, GameKit passes a match object to a [`GKMatchmakerViewControllerDelegate`](/documentation/GameKit/GKMatchmakerViewControllerDelegate) method or a [`GKMatchmaker`](/documentation/GameKit/GKMatchmaker) handler when you set up a multiplayer game. For details, see [Finding multiple players for a game](/documentation/GameKit/finding-multiple-players-for-a-game).

If you use the [`GKMatchmakerViewController`](/documentation/GameKit/GKMatchmakerViewController) class to find players, implement the [`matchmakerViewController(_:didFind:)`](/documentation/GameKit/GKMatchmakerViewControllerDelegate/matchmakerViewController(_:didFind:)) delegate method to set the match delegate. If you use the [`GKMatchmaker`](/documentation/GameKit/GKMatchmaker) class, set the match delegate in the handler you pass to the [`findMatch(for:withCompletionHandler:)`](/documentation/GameKit/GKMatchmaker/findMatch(for:withCompletionHandler:)) method.

You can begin exchanging data when two or more players join the match. Implement the [`match(_:player:didChange:)`](/documentation/GameKit/GKMatchDelegate/match(_:player:didChange:)-8ohgr) delegate method to track when players connect or disconnect from the match. Then use either the [`sendData(toAllPlayers:with:)`](/documentation/GameKit/GKMatch/sendData(toAllPlayers:with:)) or the [`send(_:to:dataMode:)`](/documentation/GameKit/GKMatch/send(_:to:dataMode:)) method to send data. To process the data on the recipient side, implement the [`match(_:didReceive:fromRemotePlayer:)`](/documentation/GameKit/GKMatchDelegate/match(_:didReceive:fromRemotePlayer:)) delegate method.

To implement voice chat, use the [`voiceChat(withName:)`](/documentation/GameKit/GKMatch/voiceChat(withName:)) method to create one or more voice channels represented by the returned [`GKVoiceChat`](/documentation/GameKit/GKVoiceChat) object.

When you’re finished with a match, call the [`disconnect()`](/documentation/GameKit/GKMatch/disconnect()) method and set the match’s delegate to `nil`. Otherwise, GameKit may send [`match(_:player:didChange:)`](/documentation/GameKit/GKMatchDelegate/match(_:player:didChange:)-8ohgr) to the delegate until all players disconnect from the match.

## Topics

### Setting the delegate

[`delegate`](/documentation/GameKit/GKMatch/delegate)

The delegate that handles communication between players in a match.

[`GKMatchDelegate`](/documentation/GameKit/GKMatchDelegate)

An object that receives connection status and data transmitted in a multiplayer game.

### Working with other players

[`expectedPlayerCount`](/documentation/GameKit/GKMatch/expectedPlayerCount)

The remaining number of players invited but not yet connected to the match.

[`players`](/documentation/GameKit/GKMatch/players)

The players that join the match.

### Sending data to other players

[`-  chooseBestHostingPlayerWithCompletionHandler:`](/documentation/GameKit/GKMatch/chooseBestHostingPlayer(completionHandler:))

Determines the best player in the game to act as the server for a client-server topology.

[`-  sendData:toPlayers:dataMode:error:`](/documentation/GameKit/GKMatch/send(_:to:dataMode:))

Transmits data to one or more players connected to the match.

[`-  sendDataToAllPlayers:withDataMode:error:`](/documentation/GameKit/GKMatch/sendData(toAllPlayers:with:))

Transmits data to all players connected to the match.

[`SendDataMode`](/documentation/GameKit/GKMatch/SendDataMode)

The mechanism used to transmit data to other players.

### Joining a voice chat

[`-  voiceChatWithName:`](/documentation/GameKit/GKMatch/voiceChat(withName:))

Joins the local player to a voice channel.

### Getting matchmaking properties

[`properties`](/documentation/GameKit/GKMatch/properties)

The local player’s properties that matchmaking rules used to find the players with some additions.

[`playerProperties`](/documentation/GameKit/GKMatch/playerProperties)

The properties for other players that matchmaking rules uses to find players, with some additions.

[`GKMatchProperties`](/documentation/GameKit/GKMatchProperties)

A type for game-specific properties that Game Center uses to find players when using matchmaking rules.

### Finishing the match

[`-  disconnect`](/documentation/GameKit/GKMatch/disconnect())

Disconnects the local player from the match.

[`-  rematchWithCompletionHandler:`](/documentation/GameKit/GKMatch/rematch(completionHandler:))

Creates a new match with the players from an existing match.

### Deprecated Methods and Properties

[`-  chooseBestHostPlayerWithCompletionHandler:`](/documentation/GameKit/GKMatch/chooseBestHostPlayer(completionHandler:))

Determines the best player in the game to act as the server for a client-server match.

[`playerIDs`](/documentation/GameKit/GKMatch/playerIDs)

The player identifiers for remote players in the match.

[`-  sendData:toPlayers:withDataMode:error:`](/documentation/GameKit/GKMatch/send(_:toPlayers:with:))

Transmits data to a list of connected players.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)