0
在an iPhone app我獲取由下面的代碼遊戲中心本地球員GameCenterViewController.m:爲什麼localPlayer.displayName是「我」?
- (void)fetchUser
{
__weak GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {
if (viewController != nil) {
[self presentViewController:viewController
animated:YES
completion:nil];
} else if (localPlayer.isAuthenticated) {
NSLog(@"%s: displayName=%@ playerID=%@", __PRETTY_FUNCTION__,
[localPlayer displayName],
[localPlayer playerID]);
User *user = [[User alloc] init];
user.userId = [localPlayer playerID];
user.firstName = [localPlayer displayName];
[user save];
dispatch_async(dispatch_get_main_queue(), ^(void){
[self performSegueWithIdentifier: @"replaceGameCenter" sender: self];
});
}
NSLog(@"%s: error=%@", __PRETTY_FUNCTION__, error);
};
}
相應的調試器輸出和屏幕截圖低於:
__37-[GameCenterViewController fetchUser]_block_invoke: displayName=Me playerID=G:216741811
__37-[GameCenterViewController fetchUser]_block_invoke: error=(null)
爲什麼我在那裏得到「我」而不是「farber72」?