为什么 ios return 游戏中心的 GKLocalPlayer 在验证成功时无效
why GKLocalPlayer from game center in ios return nill when authenticate succeeded
我在 ios 9 中使用了演示来测试游戏中心,[GKLocalPlayer localPlayer]
returns 正确的信息,但是当我在我的应用程序中使用时,它 returns 没有。我找不到 why.The 演示和应用程序使用相同的包标识符和签名。
谁知道答案,请帮帮我!
抱歉英语不好,希望你能理解他们。
会不会是线程复杂引起的?
请回答我!!!!!
求解答!!!!
求救!!
See a code sample
//here is some of codes i use;
- (void)authenticateLocalUser : (bool)bLoginGame{
if(!gameCenterAvailable)
{
return;
}
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO)
{
[GKLocalPlayer localPlayer].authenticateHandler=^(UIViewController* viewcontroller, NSError *error) {
if(viewcontroller != nil)
{
if(bLoginGame)
{
[g_sharedInstanceAppDelegate.viewController presentViewController:viewcontroller animated:YES completion:nil];
}
}
else if(error == nil && [GKLocalPlayer localPlayer].authenticated)
{
if(bLoginGame)
{
NSString* uid = [GKLocalPlayer localPlayer].playerID;
NSString* name = [GKLocalPlayer localPlayer].displayName;
GameCenterLoginCallback(uid, name, nil, false);
}
}
else
{
NSLog(@"LOGIN FAILED!");
if(bLoginGame)
{
GameCenterLoginCallback(nil, nil, error, true);
}
}
};
}
else{
NSLog(@"Already authenticated!");
if(bLoginGame)
{
NSString* uid = [GKLocalPlayer localPlayer].playerID;
NSString* name = [GKLocalPlayer localPlayer].displayName;
GameCenterLoginCallback([GKLocalPlayer localPlayer].playerID, name, nil, false);
}
}
很遗憾没有人给我正确的答案...
但是今天我突然发现为什么[GKLocalPlayer localPlayer]信息为零.....所以我写在这里,因为有些人可能需要......
Edit scheme->Run->Diagnostics->unselect [enable address sanitizer].
这将解决 question.But 不知道为什么造成的问题。
我在 ios 9 中使用了演示来测试游戏中心,[GKLocalPlayer localPlayer]
returns 正确的信息,但是当我在我的应用程序中使用时,它 returns 没有。我找不到 why.The 演示和应用程序使用相同的包标识符和签名。
谁知道答案,请帮帮我! 抱歉英语不好,希望你能理解他们。 会不会是线程复杂引起的? 请回答我!!!!! 求解答!!!! 求救!! See a code sample
//here is some of codes i use;
- (void)authenticateLocalUser : (bool)bLoginGame{
if(!gameCenterAvailable)
{
return;
}
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO)
{
[GKLocalPlayer localPlayer].authenticateHandler=^(UIViewController* viewcontroller, NSError *error) {
if(viewcontroller != nil)
{
if(bLoginGame)
{
[g_sharedInstanceAppDelegate.viewController presentViewController:viewcontroller animated:YES completion:nil];
}
}
else if(error == nil && [GKLocalPlayer localPlayer].authenticated)
{
if(bLoginGame)
{
NSString* uid = [GKLocalPlayer localPlayer].playerID;
NSString* name = [GKLocalPlayer localPlayer].displayName;
GameCenterLoginCallback(uid, name, nil, false);
}
}
else
{
NSLog(@"LOGIN FAILED!");
if(bLoginGame)
{
GameCenterLoginCallback(nil, nil, error, true);
}
}
};
}
else{
NSLog(@"Already authenticated!");
if(bLoginGame)
{
NSString* uid = [GKLocalPlayer localPlayer].playerID;
NSString* name = [GKLocalPlayer localPlayer].displayName;
GameCenterLoginCallback([GKLocalPlayer localPlayer].playerID, name, nil, false);
}
}
很遗憾没有人给我正确的答案... 但是今天我突然发现为什么[GKLocalPlayer localPlayer]信息为零.....所以我写在这里,因为有些人可能需要......
Edit scheme->Run->Diagnostics->unselect [enable address sanitizer].
这将解决 question.But 不知道为什么造成的问题。