Я пытаюсь воспроизвести звук одним нажатием кнопки. Но когда я запускаю приложение, он падает, и я получаю 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