Contents

setConnectionState(_:completionHandler:)

Sets the connection state for the player.

Declaration

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

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.

See Also

Connecting Players for Real-Time Communication