我是 iOS 新手,正在尝试编写一款有趣的回合制 iOS 游戏。我现在正在尝试对本地用户进行身份验证,并且虽然此代码构建(尽管带有保留周期警告),但它始终无法通过 GameCenter 进行身份验证。
// Authenticate the local user.
- (void)authenticateLocalUser
{
if (!gameCenterAvailable) return;
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer setAuthenticateHandler:(^(UIViewController* viewcontroller, NSError *error)
{
    //[localPlayer authenticateWithCompletionHandler:^(NSError *error) { OLD CODE!
    if (localPlayer.isAuthenticated)
    {
        // Do some stuff.
    }
    else
    {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"NOT AUTHORISED"
                                  message:@"YOUR'RE NOT LOGGED INTO GC."
                                  delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
}
)];
}
我的旧代码仍然有效,但在 iOS6 中被贬低了:
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO)
{
    [[GKLocalPlayer localPlayer]
     authenticateWithCompletionHandler:nil];
}
else
{
    NSLog(@"Already authenticated!");
}
有什么建议么?