2011-12-06 45 views
-1

当我运行这个程序时,它总是显示程序接收到的信号SIGABRT。以下是我修改的代码,特别是AVAudioPlayer。我的代码有问题吗?问题是什么?下面是断点:int retVal = UIApplicationMain(argc, argv, nil, nil);程序接收到的信号SIGABRT运行时

-(IBAction) start { 
     { 
     self.playBgMusic.enabled = YES; 
     [self.player play]; 
     } 
    } 

    -(IBAction) stop { 
     { 
      self.playBgMusic.enabled = NO; 
      [self.player stop]; 
     } 
    } 

    -(void) audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)completed 
    { 
     if(completed == YES){ 
      self.playBgMusic.enabled = YES; 
     } 
    } 


    - (void)viewDidLoad 
    { 

     NSString *path = [[NSBundle mainBundle] pathForResource:@"music" ofType:@"mp3"]; 
     self.player=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 
     player.delegate = self; 
     [player play]; 
     player.numberOfLoops = -1; 

     [super viewDidLoad]; 
    } 


    - (void)viewDidUnload 
    { 
     [player stop]; 
     [super viewDidUnload]; 

    } 
+2

您应该发布有关该问题的更多信息,而不是程序本身。 SIGABRT常见,可能由许多事情引起。我怀疑你不知道什么是SIGABRT,所以你可以在这里阅读: [SIGABRT](http://en.wikipedia.org/wiki/SIGABRT)。 堆栈上的其他问题:[StackOverflow中的SIGABRT的其他主题](http://stackoverflow.com/search?q=SIGABRT)) - 可能会帮助你或至少他们肯定会帮助你。 – Rolice

回答

0

您可能需要保留self.player,虽然这不是从你的代码清晰。如果您已经定义player(正确)为:

@property (nonatomic, retain) AVAudioPlayer *player; 

...那么你有一个不同的问题。

+0

我已经定义了播放器。这里是断点。 int retVal = UIApplicationMain(argc,argv,nil,nil); – Amink

+0

问题解决了。谢谢 – Amink

相关问题