为啥 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,为啥它受到保护?

为啥需要softmax函数?为啥不简单归一化?

为啥 g++ 需要 libstdc++.a?为啥不是默认值?

为啥或为啥不在 C++ 中使用 memset? [关闭]

为啥临时变量需要更改数组元素以及为啥需要在最后取消设置?

为啥 CAP 定理中的 RDBMS 分区不能容忍,为啥它可用?