AVAudioPlayer导致ARC下的泄漏

时间:2012-11-10 13:29:37

标签: objective-c memory-leaks automatic-ref-counting avaudioplayer

我有一个提供音乐播放器的课程,在ARC下编译。这是初始化代码:

- (id) init{
  self = [super init];
  runningVolumeNotification = FALSE;

  MPMusicPlayerController *musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
  systemVolume = musicPlayer.volume;

  NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"servo" ofType:@"mp3"];
  AVAudioPlayer* p = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL];
  [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
  [p prepareToPlay];
  [p stop];

  return self;

}

仪器报告该线100%泄漏:

AVAudioPlayer* p = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL];

enter image description here

我无法弄清问题在哪里!

0 个答案:

没有答案