ios - 错误 : Unexpected '@' in program

标签 ios xcode

<分区>


这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助 future 的读者。

关闭 9 年前

我收到以下错误。

程序中出现意外的“@”。

我的代码如下:

SKTexture* eyeTexture1 = [SKTexture textureWithImageNamed:@"eye1"];
eyeTexture1.filteringMode = SKTextureFilteringNearest;
SKTexture* eyeTexture2 = [SKTexture textureWithImageNamed:@"eye2"];
eyeTexture2.filteringMode = SKTextureFilteringNearest;

    SKAction* flap = [SKAction repeatActionForever: [SKAction animateWithTextures:@[eyeTexture1,      eyeTexture2] timePerFrame:0.2]];

_eye = [SKSpriteNode spriteNodeWithTexture:eyeTexture1];
[_eye setScale:2.0];
_eye.position = CGPointMake(self.frame.size.width / 4, CGRectGetMidY(self.frame));
[_eye runAction:flap];

}
@end //this is where the error occurs.

我已经检查了这里的其他答案,但它们没有解决我的问题。 谢谢

编辑:作为回应,代码在@implementation 中,由于堆栈溢出的“更多代码,更多细节”问题,我无法添加更多代码。有一个大括号打开它。

最佳答案

您的 .m 文件顶部需要有一个匹配的“@implementation”。

例如:

@implementation MyGameCode

…
…
…

@end

关于ios - 错误 : Unexpected '@' in program,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22290856/

上一篇:ios - 将 PDF 文件保存到 iBooks。

下一篇:ios - 如何传递 objective-c 中的指针?

相关文章:

ios - 在 Swift 中使用 XMLParser 解析特定标签并保存为字符串

ios - 为什么不用指针变量

iphone - 如何通过按钮退出应用程序?

ios - 在 MKMapView : NSInvalidArgumentException NSSetM removeObject: object cannot be nil 上使用叠加层缩放时出现异常

上传到 App Store 时 Xcode 出错 : "No suitable application records were found"

ios - 更新 Swift 语言 : Type 'NSCoder' has no member 'plain'

ios - 谓词中的逻辑运算符是否与 NSFetchRequest 短路?

ios - 是否有可能在 iOS 罗盘航向中获得低于度数的精度?

ios - 更改 UIView 框架

iphone - 当我的同事更改代码并将其提交到存储库时,我可以看到代码,但 xCode 编译时就好像他的贡献不存在一样