1

当我尝试在 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);
}
4

2 回答 2

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
于 2012-11-21T05:00:55.080 回答
0

您在行中缺少-sender` 的实施之前:

(IBAction)PlaySound1:(id)sender1:(id)sender { 
于 2012-11-21T04:51:54.533 回答