1
所以,我注意到在調用initializeGameCenter()一次之後,每次我的應用程序回到前臺時,下面的塊(在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];
}];
}