I initialize an ivar AVAudioPlayer variable, play and the try to release its memory. After the release line, it doesn’t set to 0x0. After the nil line it doesn’t change to 0x0. Does AVAudioPlayer require something special to release its memory?
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource: @"mysound" ofType: @"aif" inDirectory:@"/"]] error: &err];
audioPlayer.numberOfLoops = 0;
audioPlayer.volume = .5;
[audioPlayer prepareToPlay];
[audioPlayer play];
[audioPlayer release];
audioPlayer = nil;
Well,
AVAudioPLayer plays the audio files asynchronously. You should not release the player after you start playing, it may lead to some memory related error and your audio file may not play too.
You should release the player via avaudioplayerdelegate. For more details you can check this answer too.
Hope this helps.
Thanks,
Madhup