views:

39

answers:

1

I get this random error when I run my app on my iPhone.

First, I tap this method-

-(IBAction)playBeat1 {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"beat1" ofType:@"mp3"];
    AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 

    [theAudio play];
    NSLog(@"Beatmaker");    
}

Then when I tap this (It changes Views)-

-(IBAction) back{   
    [self dismissModalViewControllerAnimated:YES];
}

I get this error

UIView willMoveToSuperview:]: message sent to deallocated instance 0x1b1a20

Any Ideas?

+3  A: 

You are dismissing a modal view controller that is already deallocated. The best way to deal with this is to activate NSZombies (search on SO). But if you show us where you present the modal view, we can probably give you more advice. My guess is that you should use this instead:

[self.parentViewController dismissModalViewControllerAnimated:YES];

But I would have to see more code to know.

playBeat1 doesn't seem to have anything to do with your problem.

Felixyz
Fixed my problem!!!! I no longer get that error when I switch back! Thank you so much! I also did activate NSZombies earlier! Thank you!
Henry D'Andrea