Instance Method

cancelWithLocalizableMessageKey:arguments:completionHandler:

Cancels an exchange.

Declaration

- (void)cancelWithLocalizableMessageKey:(NSString *)key arguments:(NSArray<NSString *> *)arguments completionHandler:(void (^)(NSError *error))completionHandler;

Parameters

key

A string in the Localizable.strings file for the current localization.

arguments

An array of objects to be substituted using the format string.

completionHandler

A block to be called after the cancel event has been sent.

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

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.

It is possible to cancel both active and complete exchanges. When an exchange is cancelled, a push notification is sent to each participant using the localizable message. An error is returned if the exchange has previously been cancelled.

See Also

Responding to an Exchange

completionDate

The date when the exchange was completed.

data

Data that is sent with the exchange.

exchangeID

A persistent identifier that is used when referring to this exchange.

message

The localized message that is pushed to all of the recipients of the exchange.

recipients

The players to receive the exchange.

replies

List of exchange replies.

sendDate

The date that the exchange was sent out.

sender

The participant who sent the exchange.

status

The current status of the exchange.

GKTurnBasedExchangeStatus

The status of an exchange or reply.

timeoutDate

The amount of time the exchange is to stay active before timing out.