我试图通过单击按钮播放声音。但是,当我运行应用程序崩溃,我得到Thread 1 : signal SIGABRT
。我的应用程序在播放声音时崩溃
这是我的代码:
.h文件中
#import <AVFoundation/AVFoundation.h>
@interface HljodViewController : UIViewController <AVAudioPlayerDelegate>{
}
-(IBAction)playsound;
.m文件
-(IBAction)playsound {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Geese_4" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.numberOfLoops = 1;
[theAudio play];
}
新增了[一般异常断点(https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator /articles/adding_an_exception_breakpoint.html#//apple_ref/doc/uid/TP40010433-CH1-SW1)。 – rckoenes