Retrieving the Local Player’s Information
Problem
You have authenticated the local player, but you need to get her alias and other information.
Solution
Use different properties available to the GKLocalPlayer class, such as the alias property, as demonstrated in the
Discussion section.
Discussion
The GKPlayer object represents
a player in Game Center. Each player possesses a few very important
properties:
playerIDEach player in Game Center has an identifier. This identifier should not be displayed to the player. Instead, the player alias is what the player is interested in seeing in leaderboards, etc. In many Game Center methods, we will first be able to retrieve players’ IDs and use them to load other information for the player, such as her scores in a specific leaderboard. In other words, player IDs are important only when working with Game Center APIs.
aliasThe alias that the player sets for herself during the registration process in Game Center. You can display this alias to the player if you wish.
isFriendThis property returns a value of type BOOL, allowing you to determine whether the player is the friend of the currently authenticated local player.
This is a property of the
GKPlayerclass only. Although theGKLocalPlayerclass subclassesGKPlayer, theisFriendproperty cannot be accessed in theGKLocalPlayerclass.
Now let’s go ahead and demonstrate this with example code. In this code, what I want to demonstrate can be separated into two pieces of code expressed in block objects. ...