Type Method

createSessionInContainer:withTitle:maxConnectedPlayers:completionHandler:

Creates a new game session inside of an iCloud container.

Declaration

+ (void)createSessionInContainer:(NSString *)containerName withTitle:(NSString *)title maxConnectedPlayers:(NSInteger)maxPlayers completionHandler:(void (^)(GKGameSession *session, NSError *error))completionHandler;

Parameters

containerName

A String value representing the iCloud container for the game session.

title

A String value representing the title of the game session.

maxPlayers

An Integer value indicating the maximum number of players allowed in the game session.

completionHandler

A block that is called after a new game session has been created.

gameSession

A GKGameSession object containing information about the newly created game session.

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

The container name must be a valid iCloud container associated with your app. After a user has finished a game and is done with a game session, remove the created game session from iCloud using removeSessionWithIdentifier:completionHandler:. See iCloud Design Guide for more information on incorporating iCloud in your app.

See Also

Creating and Loading Game Sessions

+ loadSessionWithIdentifier:completionHandler:

Loads a specific game session.

Deprecated
+ loadSessionsInContainer:completionHandler:

Retrieves all of the game sessions associated with a container.

Deprecated
+ removeSessionWithIdentifier:completionHandler:

Removes the specified game session.

Deprecated