我只是将这段代码从 apple dev libary 复制/粘贴到 xcode 中,而 xcode 给了我很多基本的语法错误..
- (void) authenticateLocalPlayer
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil)
{
[self showAuthenticationDialogWhenReasonable: viewController
}
else if (localPlayer.isAuthenticated)
{
[self authenticatedPlayer: localPlayer];
}
else
{
[self disableGameCenter];
}
}];
}
我做错了什么吗?
最佳答案
我怀疑您需要针对 iOS6 而不是。如果我以 iOS 5.x 为目标,我的编译器也会生成错误。文档声明 @property authenticateHandler 的可用性仅适用于 iOS6。
此外,语法错误在 block 的第一个 if 子句中的 viewController 之后缺少右括号和分号。
关于ios - 使用 Apple Dev 代码时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12574259/