小编Jon*_*ail的帖子

Xcode问题!期待";" 方法原型之后

我刚刚开始使用Xcode,我正和一些朋友一起制作一个简单的音板应用程序.

我遇到了第一行的问题.我已经编写了代码,我很确定它是正确的,但我不明白为什么会这样!我得到了一个"预期的";' 在方法原型之后"并尝试了一切来解决它,只需插入分号就会给我带来3个错误.这是我的代码

'#import "ViewController.h"'

@interface ViewController ()

// Sound for Ben
- (IBAction)playsound1 { // this is where the error is. It is not on any other line

NSString *path = [[NSBundle mainBundle] pathForResource:@"Ben" ofType:@"mp3"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];

theAudio.delegate=self;
[theAudio play];
}
// Sound for Bruno
- (IBAction)playsound2 {

NSString *path = [[NSBundle mainBundle] pathForResource:@"Bruno" ofType:@"mp3"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL    fileURLWithPath:path] error:NULL];

theAudio.delegate=self;
[theAudio play];
}
// Sound for Homer
- (IBAction)playsound3 {

NSString *path = …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c

1
推荐指数
1
解决办法
6945
查看次数

标签 统计

objective-c ×1

xcode ×1