Actually it is the opposite of a leak. If you do not retain the player, it will be released immediately and will never play.
See my answer here for more info: Playing back audio using AVAudioPlayer iOS 7
سؤال
I'm new to playing sounds on iOS. I know that to play various sounds I should have a audio manager helper class keeping all the audios together.
Now, I'm wondering if it is OK to do this without memory leak:
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err];
[newPlayer play];
Will the player get released after it finished playing? Or do I need to keep a pointer to it, call [newPlayer stop]
when it finishes, then set the pointer to nil
?
المحلول
Actually it is the opposite of a leak. If you do not retain the player, it will be released immediately and will never play.
See my answer here for more info: Playing back audio using AVAudioPlayer iOS 7