<!--
{
  "availability" : [
    "iOS: 10.0.0 - 12.0.0",
    "iPadOS: 10.0.0 - 12.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.12.0 - 10.14.0",
    "tvOS: 10.0.0 - 12.0.0",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKGameSession/setConnectionState(_:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKGameSession(im)setConnectionState:completionHandler:"
  },
  "title" : "setConnectionState(_:completionHandler:)"
}
-->

# setConnectionState(_:completionHandler:)

Sets the connection state for the player.

```
func setConnectionState(_ state: GKConnectionState, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`state`

The `GKConnectionState` to be assigned to the player.

`completionHandler`

A block that is called after the connect state has been set.

- error: If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil. See `GameKit Constants` for a list of error codes specific to GameKit.

## Discussion

This method will fail when the game session’s player limit has already been reached or there are network problems. The game session’s `lastModifiedDate` and `lastModifiedPlayer` properties are updated on completion.

---

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)