AVAudioPlayer에 할당 한 메모리를 해제하고 싶습니다.하지만 사운드를 재생하려고 시도했을 때 사운드가 재생되지 않습니다. 잠재적 인 메모리 누수가 있습니다. 어떻게하면 빠져 나올 수 있습니까? 이.아래의 코드에서 AVAudioPlayer를 해제하는 방법
잘못된 선택을 선택한 다음 오류 사운드를 재생할 때 아래의 코드가 사용됩니다. 여러 번 잘못된 선택을 선택하면 여러 번 할당되어 어떻게 제거 될 수 있습니다.
else
{
NSString *[email protected]"Error.mp3";
NSError *error;
NSURL *urlString = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%s", [[NSBundle mainBundle] resourcePath],[soundName UTF8String]]];
AVAudioPlayer *worngAudioPlay = [[AVAudioPlayer alloc] initWithContentsOfURL:urlString error:&error];// here I also used to release using autorelease then not played sound
worngAudioPlay.delegate = self;
if (worngAudioPlay == nil)
{
}
else
{
[worngAudioPlay play];
}
// [worngAudioPlay release]; // Here I released then not played sound
}
감사합니다. Madan Mohan.
안녕하세요,하지만 멈췄을 때이 메서드는 호출되지 않습니다. –
@Madan Mohan은 정확한 방법 이름을 기억하지 못합니다. avaudioplayer 클래스 문서 –