Instance Method

match(for:completionHandler:)

Creates a match from an accepted invitation.

Declaration

func match(for invite: GKInvite, completionHandler: ((GKMatch?, Error?) -> Void)? = nil)

Parameters

invite

The invitation accepted by the player.

completionHandler

A block to be called when the match has been created. This block receives the following parameters:

match

If the match was successfully created, this parameter contains the created match. Otherwise, this parameter is nil.

error

If the match was successfully created, this parameter contains nil. Otherwise, this parameter holds an error object that describes the error that occurred.

Discussion

When using this method to create a match, your game should display its own user interface to inform the player that he or she has been connected to a match.

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.

See Also