i m trying to play background.mp3 files as my game playback file ,and it works fine but it leaking memory
@interface slots2ViewController : UIViewController <AVAudioPlayerDelegate>
{
AVAudioPlayer *PlayBack;
}
@property(nonatomic, retain) AVAudioPlayer *PlayBack ;
.m file
@synthesize PlayBack;
-(void)LoadnPlaySound
{
NSString *SubDir = [NSString stringWithFormat:@"AudioFiles/Theme%d",SlotId];
NSURL* file_url2 = nil;
file_url2 = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"background"ofType:@"mp3" inDirectory:SubDir ]];
AVAudioPlayer* TmpPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:file_url2 error:nil];
self.PlayBack = TmpPlayer;
self.PlayBack.delegat开发者_如何学Goe = self;
[TmpPlayer release];
[self.PlayBack prepareToPlay];
[self.PlayBack play];
[release file_url2];
}
-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)ThePlayer successfully:(BOOL)flag
{
[self.PlayBack play];
}
memory leak instrument says [self.PlayBack prepareToPlay] is the point of 100% leak i m calling LoadnPlaySound whenever i m changing the theme. also do i need to release self.PlayBack if yes then where
精彩评论