Transmits data to a list of connected players.
SDKs
- iOS 4.1–8.0Deprecated
- macOS 10.8–10.10Deprecated
- Mac Catalyst 13.0–13.0Deprecated
Framework
- Game
Kit
Declaration
func send(_ data: Data, toPlayers playerIDs: [String], with mode: GKMatch.Send Data Mode) throws
Parameters
data
The bytes to be sent.
playerIDs
An array of
NSString
objects containing the identifier strings for the list of players who should receive the data.mode
The mechanism used to send the data.
error
If the data could not be queued, on return, this parameter holds an
NSError
object describing the error.
Return Value
true
if the data was successfully queued for transmission; false
if the match was unable to queue the data.
Discussion
The match queues the data and transmits it when the network becomes available.
Handling Errors in Swift:
In Swift, this method returns Void
and is marked with the throws
keyword to indicate that it throws an error in cases of failure.
You call this method in a try
expression and handle any errors in the catch
clauses of a do
statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.