---
title: GKMatch
framework: gamekit
role: symbol
role_heading: Class
path: gamekit/gkmatch
---

# GKMatch

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

## Declaration

```swift
class GKMatch
```

## Mentioned in

Finding multiple players for a game Assigning players to teams using rules Creating activities for your game

## Overview

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 method or a GKMatchmaker handler when you set up a multiplayer game. For details, see Finding multiple players for a game. If you use the GKMatchmakerViewController class to find players, implement the matchmakerViewController(_:didFind:) delegate method to set the match delegate. If you use the GKMatchmaker class, set the match delegate in the handler you pass to the findMatch(for:withCompletionHandler:) method. You can begin exchanging data when two or more players join the match. Implement the match(_:player:didChange:) delegate method to track when players connect or disconnect from the match. Then use either the sendData(toAllPlayers:with:) or the send(_:to:dataMode:) method to send data. To process the data on the recipient side, implement the match(_:didReceive:fromRemotePlayer:) delegate method. To implement voice chat, use the voiceChat(withName:) method to create one or more voice channels represented by the returned GKVoiceChat object. When you’re finished with a match, call the disconnect() method and set the match’s delegate to nil. Otherwise, GameKit may send match(_:player:didChange:) to the delegate until all players disconnect from the match.

## Topics

### Setting the delegate

- [delegate](gamekit/gkmatch/delegate.md)
- [GKMatchDelegate](gamekit/gkmatchdelegate.md)

### Working with other players

- [expectedPlayerCount](gamekit/gkmatch/expectedplayercount.md)
- [players](gamekit/gkmatch/players.md)

### Sending data to other players

- [chooseBestHostingPlayer(completionHandler:)](gamekit/gkmatch/choosebesthostingplayer(completionhandler:).md)
- [send(_:to:dataMode:)](gamekit/gkmatch/send(_:to:datamode:).md)
- [sendData(toAllPlayers:with:)](gamekit/gkmatch/senddata(toallplayers:with:).md)
- [GKMatch.SendDataMode](gamekit/gkmatch/senddatamode.md)

### Joining a voice chat

- [voiceChat(withName:)](gamekit/gkmatch/voicechat(withname:).md)

### Getting matchmaking properties

- [properties](gamekit/gkmatch/properties.md)
- [playerProperties](gamekit/gkmatch/playerproperties.md)

### Finishing the match

- [disconnect()](gamekit/gkmatch/disconnect().md)
- [rematch(completionHandler:)](gamekit/gkmatch/rematch(completionhandler:).md)

### Deprecated Methods and Properties

- [chooseBestHostPlayer(completionHandler:)](gamekit/gkmatch/choosebesthostplayer(completionhandler:).md)
- [playerIDs](gamekit/gkmatch/playerids.md)
- [send(_:toPlayers:with:)](gamekit/gkmatch/send(_:toplayers:with:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Real-time games

- [Creating real-time games](gamekit/creating-real-time-games.md)
- [Finding multiple players for a game](gamekit/finding-multiple-players-for-a-game.md)
- [Exchanging data between players in real-time games](gamekit/exchanging-data-between-players-in-real-time-games.md)
- [Adding voice chat to multiplayer games](gamekit/adding-voice-chat-to-multiplayer-games.md)
- [Finding players for custom server-based games](gamekit/finding-players-for-custom-server-based-games.md)
- [Matchmaking rules](gamekit/matchmaking-rules.md)
- [GKMatchRequest](gamekit/gkmatchrequest.md)
- [GKMatchmaker](gamekit/gkmatchmaker.md)
- [GKMatchmakerViewController](gamekit/gkmatchmakerviewcontroller.md)
- [GKInviteEventListener](gamekit/gkinviteeventlistener.md)
- [GKInvite](gamekit/gkinvite.md)
