我正在尝试在我的新应用中实施游戏中心,我正在按照
的教程进行操作http://www.appcoda.com/ios-game-kit-framework/
我遵循相同的程序,但不幸的是我无法在这里编织它是我的代码
-(void)authenticateLocalPlayer{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil) {
[self presentViewController:viewController animated:YES completion:nil];
}
else{
if ([GKLocalPlayer localPlayer].authenticated) {
_gameCenterEnabled = YES;
// Get the default leaderboard identifier.
[[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {
if (error != nil) {
NSLog(@"%@", [error localizedDescription]);
}
else{
_leaderboardIdentifier = leaderboardIdentifier;
}
}];
}
else{
_gameCenterEnabled = NO;
}
}
};
}
我正在迈出第一步,我正在对播放器进行身份验证,但是当我按照教程中的描述构建和运行时,我会看到“使用未声明的标识符”这一行的错误。
_gameCenterEnabled = YES; ------ Use of undeclared identifier '_gameCenterEnabled'
_leaderboardIdentifier = leaderboardIdentifier;----- Use of undeclared identifier 'leaderboardIdentifier'
_gameCenterEnabled = NO;---- Use of undeclared identifier '_gameCenterEnabled'
答案 0 :(得分:0)
您必须先将_gameCenterEnabled
和_leaderboardIdentifier
声明为属性。
@property(nonatomic, strong) NSString *leaderboardIdentifier;
@property(nonatomic, assign) BOOL gameCenterEnabled;