I’m not quite to the bottom of things yet, but I have observed something that, I think, throws a kink in the book’s logic.
When I set up my tester account, apple assigned a name of “Player_4939364543”, I didn’t really like that, so I worked to change it to “App Tester 2” on my simulator. When I get into the addPlayer()
function, I’ve received “App Tester 2” from the loadGameCenterGame()
function, but already have “Player_4939364543” loaded.
As you can see from the debugging variables, both the existing players[0] and the player I’m adding have a player ID of “A:_d1bd1278a67fdab60ac1de3fc6089d18”, but have different names. I would take that to mean that the playerId (alone) uniquely identifies the player, and that trying to look the player up by name is misguided.
I’m not positive, but suspect that this will be a factor in tracking down this behavior.
I hate to keep dragging folks through troubleshooting my typos, but in this case, I’m pretty sure that this is a real-world scenario that the code in the book should handle correctly. (people are going to be able to rename their players (which apparently gives them a different name locally (??? - really foggy on this so far)))