そのため、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];
}];
}