Deprecated GKLocalPlayer Methods

A method identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in iOS 6.0

authenticateWithCompletionHandler:

Authenticates the local player on the device. (Deprecated in iOS 6.0. Set the authenticateHandler property instead.)

- (void)authenticateWithCompletionHandler:(void (^)(NSError *error))completionHandler
Parameters
completionHandler

A block to be called when the player has authenticated or when an error occurs.

The block takes the following parameter:

error

This parameter is nil if the player successfully authenticated. Otherwise, it contains an error object that describes the error that occurred.

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.

Your game should authenticate the player as early as possible after launching, ideally as soon as you can present a user interface to the player. For example, your game may be launched because the player accepted an invitation to join a match or to take a turn in a turn-based match, so you want your game to authenticate the player and process the match invitation as quickly as possible.

If there is not an authenticated player on the device when your game calls this method, Game Kit displays a user interface that allows the player to sign in with their credentials (or to create a new account if he or she has never used Game Center). Your game should pause other activities that require user interaction (such as a real time game loop) before attempting to authenticate the local player.

Game Kit maintains a strong reference to your completion handler even after successfully authenticating a local player. If your game moves into the background, Game Kit automatically authenticates the player again whenever your game moves back to the foreground. Game Kit calls your same completion handler each time it authenticates the local player. Be mindful that in block programming, any Objective-C object referenced inside a block is also strongly referenced by the block until the block is released. Because Game Kit maintains a strong reference to your completion handler until your game terminates, any objects referenced from within your authentication handler are also held indefinitely.

Each time the completion handler is called, the data stored in the local player singleton object may have changed. A new player may have logged into the device or the player may have simply logged out from Game Center. Because of both of these possibilities, your authentication handler must be prepared to update any other objects that assume that a particular player is logged in. For more information, see “Authenticating the Local Player in a Multitasking App” in Game Center Programming Guide.

Availability
  • Available in iOS 4.1 and later.
  • Deprecated in iOS 6.0.
Declared In
GKLocalPlayer.h

Deprecated in iOS 7.0

loadDefaultLeaderboardCategoryIDWithCompletionHandler:

Loads the category identifier for the local player’s default leaderboard. (Deprecated in iOS 7.0. Use the loadDefaultLeaderboardIdentifierWithCompletionHandler: method instead.)

- (void)loadDefaultLeaderboardCategoryIDWithCompletionHandler:(void (^)(NSString *categoryID, NSError *error))completionHandler
Parameters
completionHandler

A block to be called when the request completes.

The block receives the following parameters:

categoryID

The category ID string for the local player’s default leaderboard.

error

If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter 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.

Availability
  • Available in iOS 6.0 and later.
  • Deprecated in iOS 7.0.
Declared In
GKLocalPlayer.h

setDefaultLeaderboardCategoryID:completionHandler:

Sets the category identifier for the local player’s default leaderboard. (Deprecated in iOS 7.0. Use the setDefaultLeaderboardIdentifier:completionHandler: method instead.)

- (void)setDefaultLeaderboardCategoryID:(NSString *)categoryID completionHandler:(void (^)(NSError *error))completionHandler
Parameters
categoryID

The category ID string for one of your game’s leaderboards.

completionHandler

A block to be called when the request completes.

The block receives the following parameter:

error

If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter 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.

The default leaderboard is configured in iTunes Connect as part of configuring your game’s leaderboards. All players normally start with this leaderboard as the default leaderboard. Calling this method changes the default leaderboard only for the local player.

Availability
  • Available in iOS 6.0 and later.
  • Deprecated in iOS 7.0.
Declared In
GKLocalPlayer.h