1

そのため、initializeGameCenter() を 1 回呼び出した後、アプリケーションがフォアグラウンドに戻るたびに (authenticateWithCompletionHandler の後) 以下のブロックが呼び出されることに気付きました - これは Game Center の通常の動作ですか?? (ブレークポイントを配置して、ブロックのみが呼び出され、initializeGameCenter 自体が呼び出されないことを確認しました)

- (void)initializeGameCenter
{
    // Don't initialize Game Center unless we have access to the classes from iOS 4.1 or greater. 

    if (![self isGameCenterAvailable]) {
        return;
    }



    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {

        NSDictionary *userInfo = nil;
        if (error == nil) {
            // Game Center will present a "Welcome Back" message when we have authenticated
            GTMLoggerInfo(@"Game Center successfully authenticated");
        }
        else {
            userInfo = [NSDictionary dictionaryWithObject:error forKey:@"NSError"];
            GTMLoggerDebug(@"error authenticating game center");
        }
        [[NSNotificationCenter defaultCenter] postNotificationName:GameCenterAuthenticateDidFinishNotification
                                                            object:self
                                                          userInfo:userInfo]; 

    }];
}
4

1 に答える 1

4

ゲーム キット プログラミング ガイドから:

「 [いつ] ゲームがフォアグラウンドに戻り、Game Kit がプレイヤーを認証し、認証ハンドラーが呼び出されます。」

http://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/Users/Users.html#//apple_ref/doc/uid/TP40008304-CH8-SW11

つまり、アプリがフォアグラウンドに移動するたびに、完了ブロックが呼び出されます。-[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:]

于 2011-03-24T10:20:18.240 に答える