当我尝试在Xcode上运行我的应用程序时,我继续收到“预期方法正文”错误。粗体的地方是我收到错误的地方。救命!!!还有一件事,我继续在“@implementation SoundnoardFirstViewController”部分收到错误说“不完整的实现”。救命!!感谢
#import "SoundnoardFirstViewController.h"
@interface SoundnoardFirstViewController ()
@end
@implementation SoundnoardFirstViewController
-(IBAction)PlaySound1:(id)sender1
**-(IBAction)PlaySound2:(id)sender2**
-(IBAction)PlaySound3:(id)sender3
-(IBAction)PlaySound4:(id)sender4
-(IBAction)PlaySound5:(id)sender5
-(IBAction)PlaySound6:(id)sender6
(IBAction)PlaySound1:(id)sender1:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"This is the name of the clip", CFSTR ("sound file type"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)PlaySound2:(id)sender2:(id)sender{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"DoYouHave?", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)PlaySound3:(id)sender3:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Hello", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)PlaySound4:(id)sender4:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"SoupBetter?", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
答案 0 :(得分:2)
在SoundnoardFirstViewController ()
@interface SoundnoardFirstViewController ()
//declare the private methods here
@end
示例:强>
#import "SoundnoardFirstViewController.h"
@interface SoundnoardFirstViewController ()
-(IBAction)PlaySound1:(id)sender1:(id)sender;
-(IBAction)PlaySound2:(id)sender2:(id)sender
@end
@implementation SoundnoardFirstViewController
-(IBAction)PlaySound1:(id)sender1:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"This is the name of the clip", CFSTR ("sound file type"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)PlaySound2:(id)sender2:(id)sender{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"DoYouHave?", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
@end
答案 1 :(得分:0)
您在执行发件人之前错过了-
:
(IBAction)PlaySound1:(id)sender1:(id)sender {