I am working with GameCenter / GameKit in iOS8 to build a TurnBasedMatch. I am confused as to how to identify whether the current player (ie the one with the app running currently on the iPhone) is the one whose turn it is. The reason I am having this issue is that Apple docs say that GKTurnBasedParticipant.playerID is deprecated in iOS8.
I used to do the following: - when GameCenter authenticates: (1) store the current playerID locally (2) load the current Match (3) check if Match.currentParticipant's playerID matches the locally stored playerID and if it is then allow the player to take his turn
Now in iOS8 - currentParticipant (which is a GKTurnBasedParticipant) has playerID deprecated. So how do I know whether the currentParticipant is actually the local player?
You don't need to store the playerID to check identities. Local playerID can be accessed always with:
[GKLocalPlayer localPlayer].playerID
As to how to use playerID now that it's deprecated, that property was only moved from GKTurnBasedParticipant to GKPlayer. That doesn't affect the code that I pasted before, but it does affect the way you access to match.participants. So, for any given player, the way to access it in iOS8 would be:
GKTurnBasedParticipant *p1 = (GKTurnBasedParticipant *)self.match.participants[index];
p1.player.playerID
As you can see, you only have to add a .player to your current code.