所以我是编码的新手,我正在尝试构建我的第一个应用程序,我已经完成了所有工作,但我一直收到此错误消息。有谁能告诉我我做错了什么,如何解决这个问题好吗?感谢。
#import "JSSViewController.h"
#import "JSSMyScene.h"
@implementation JSSViewController
@import AVFoundation;
@end
@interface UIViewController ()
@property (nonatomic) AVAudioPlayer * backgroundMusicPlayer;
- (void)viewWillLayoutSubviews;
{ (this is the error)!Expected identifier or '('
[super viewWillLayoutSubviews];
NSError *error;
NSURL * backgroundMusicURL = [[NSBundle mainBudle] URLForResource:@"background-music-aac" withExtension:@"caf"];
self.backgroundMusicPlayer = [[AVAudioPlayer alloc] initWithContentsofURL:backgroundMusicURL error:&error];
self.backgroundMusicPlayer.numberOfLoops = -1;
[self.backgroundMusicPlayer prepareToPlay];
[self.backgroundMusicPlayer play];
// Configure the view.
SKView * skView = (SKView *)self.view;
if (!skView.scene) {
skView.showsFPS = YES;
skView.showsNodeCount = YES;
// Create and configure the scene.
SKScene * scene = [JSSMyScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
}
}
@end
答案 0 :(得分:0)
在代码中你不应该有;在方法签名之后你应该有
- (void)viewWillLayoutSubviews
{
....
您还需要将实现和界面分开。
在界面中你有;而且只有签名
@interface UIViewController ()
@property (nonatomic) AVAudioPlayer * backgroundMusicPlayer;
- (void)viewWillLayoutSubviews;
@end
然后是@implementation块中的代码