I'm new to using avadioplayer and I seems to have a memory when ever I play a sound. I cannot figure out what I am missing to get rid of it inside Instrument. could this be a false positive?
ViewController.h :
@interface ISpectatorViewController : UIViewController <UIAccelerometerDelegate>{
AVAudioPlayer *massCheerSoundID;
}
@property(nonatomic,retain) AVAudioPlayer * massCheerSoundID;
// ViewController.m
- (void)viewDidLoad {
NSString * filePath;
filePath = [[NSBundle mainBundle] pathForResource:@"massCheer" ofType:@"mp3"];
massCheerSoundID = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:filePath ]error:nil];
}
- (void) playSound
{
if(massCheerSoundID.playing == false)
{
massCheerSoundID.currentTime = 0.0;
//leak here
[massCheerSoundID play];
}
}
- (void)dealloc {
[super dealloc];
[massCheerSoundID release];
}
I found out what the problem is.
I for got to add the AVAudioPlayerDelegate on the interface since I've set the UIAccelerometerDelegate instead
@interface iSpectatorViewController: UIViewController<AVAudioPlayerDelegate>
and set the
massCheerSoundId.delegate = self