程序运行时接收到SIGABRT信号



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

-(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];
    }

您可能需要保留self.player,尽管这在您的代码中并不清楚。如果您已将player(正确地)定义为:

@property (nonatomic, retain) AVAudioPlayer *player;

…那你的问题就不一样了

最新更新