Instance Method

remove(completionHandler:)

Programmatically removes a match from Game Center.

Declaration

func remove(completionHandler: ((Error?) -> Void)? = nil)

Parameters

completionHandler

A block to be called after the match has been removed from Game Center.

The block receives the following parameters:

error

If an error occurred, this error object describes the error. If the operation was completed successfully, the value is nil.

Discussion

Even after a player’s participation in a match ends, the data associated with the match continues to be stored on Game Center. Storing the data on Game Center allows the player to continue to watch the match’s progress, or even see the final state of the match when it ends. However, players may also want to delete matches that they have finished playing. If you choose not to use the standard matchmaker user interface, your game should offer the ability to delete a finished match from Game Center. When a player chooses to delete a match from Game Center, call this method. It is a programming error to call this method on a match that has the local player as an active participant.

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.

When the task completes, the match is no longer visible to the local player whose device made the call. Other players involved in the match still see the match.