Game Development Reference
The first test is simply to check whether a specific Game Center class is available. In
this case, the Objective-C runtime method NSClassFromString is used to get one
of the Game Center classes by name. If this call returns nil , you can be certain that
Game Center is unavailable.
But it's not quite that simple. Because Game Center was already partially available in
beta versions prior to iOS 4.1, you also need to check whether the device is running at
least iOS 4.1. You do that by comparing the reqSysVer string with the sys-
Once both checks are made, you combine the results using the && (and) operator, so
that both must be true for isGameCenterAvailable to become true. The
isGameCenterAvailable variable is used to safeguard all calls to Game Center
functionality within the GameKitHelper class. This avoids accidentally calling
Game Center functionality when it's not available, which would crash the application.
Note that this is how Apple recommends you check for Game Center availability. You
shouldn't use any other methods—for example, determining the type of device your
game is running on. Although certain devices are excluded from using Game Center,
the preceding check already accounts for this.
Authenticating the Local Player
The local player is a fundamental concept to Game Center programming. It refers to
the player account that's signed into the device. This is important to know because only
the local player can send scores to leaderboards and report achievement progress to the
Game Center service. The very first thing a Game Center application needs to do is au-
thenticate the local player. If that fails, you can't use most of the Game Center services,
and in fact Apple recommends not using any Game Center functionality unless there is
an authenticated local player.
In the GameKitHelper init method, the registerForLocalPlayer-
AuthChange method is called so that GameKitHelper receives events concerning
authentication changes for the local player. This is the only Game Center notification