Obj-c를 처음 사용했습니다. 나는 그것이 성공하면 var 부울을 YES로 설정하는 클래스를 가지고있다. (게임 센터 로그인 = 성공), 할 일이 무엇인지, 예를 들어 YES 일 때 청취하는 var에 청취자가있다. 일부 코드. 내가 블록을 사용합니까? Sparrow 프레임 워크도 사용하고 있습니다.Objective C에서 Block을 사용하여 BOOL이 설정되었는지 확인하십시오.
여기 내 GameCenter.m 파일
-(void) setup
{
gameCenterAuthenticationComplete = NO;
if (!isGameCenterAPIAvailable()) {
// Game Center is not available.
NSLog(@"Game Center is not available.");
} else {
NSLog(@"Game Center is available.");
__weak typeof(self) weakSelf = self; // removes retain cycle error
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; // localPlayer is the public GKLocalPlayer
__weak GKLocalPlayer *weakPlayer = localPlayer; // removes retain cycle error
weakPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
{
if (viewController != nil)
{
[weakSelf showAuthenticationDialogWhenReasonable:viewController];
}
else if (weakPlayer.isAuthenticated)
{
[weakSelf authenticatedPlayer:weakPlayer];
}
else
{
[weakSelf disableGameCenter];
}
};
}
}
-(void)showAuthenticationDialogWhenReasonable:(UIViewController *)controller
{
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:controller animated:YES completion:nil];
}
-(void)authenticatedPlayer:(GKLocalPlayer *)player
{
NSLog(@"%@,%@,%@",player.playerID,player.displayName, player.alias);
gameCenterAuthenticationComplete = YES;
}
-(void)disableGameCenter
{
}
에 내 코드입니다하지만 그 gameCenterAuthenticationComplete가 YES 동일한 경우 다른 개체에서 알 필요가있다.