为啥 localPlayer.displayName 是“我”?
Posted
技术标签:
【中文标题】为啥 localPlayer.displayName 是“我”?【英文标题】:Why is localPlayer.displayName "Me"?为什么 localPlayer.displayName 是“我”? 【发布时间】:2014-02-15 14:33:42 【问题描述】:在an iPhone app我通过GameCenterViewController.m中的以下代码获取游戏中心本地玩家:
- (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)
为什么我得到的是“Me”而不是“farber72”?
【问题讨论】:
【参考方案1】:你在标题中看到的可能是玩家alias
。
【讨论】:
以上是关于为啥 localPlayer.displayName 是“我”?的主要内容,如果未能解决你的问题,请参考以下文章
为啥 DataGridView 上的 DoubleBuffered 属性默认为 false,为啥它受到保护?