Instance Method

saveGameData:withName:completionHandler:

Saves game data under the specified name.

Declaration

- (void)saveGameData:(NSData *)data withName:(NSString *)name completionHandler:(void (^)(GKSavedGame *savedGame, NSError *error))handler;

Parameters

data

An object that contains the saved game data.

name

A string that identifies the saved game data.

handler

A block to be called when the request completes.

The block receives the following parameters:

savedGame

A GKSavedGame object containing saved game information for the saved data.

error

If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.

Discussion

This method saves game data asynchronously. When a game is saved, if there is already a saved game with the same name, the new saved game data overwrites the old saved game data. If there is no saved game with the same name, a new saved game is created.

See Also

Working with Saved Games

- deleteSavedGamesWithName:completionHandler:

Deletes a specific saved game file.

- fetchSavedGamesWithCompletionHandler:

Retrieves all available saved games.