Michal Klimczak
05/19/2021, 7:59 AMAvAudioPlayer
which uses a delegate AVAudioPlayerDelegateProtocol
. Now I wanted to just use an anonymous implementation of that protocol (or a class extending it - they both work the same) and set it more or less like this
player.delegate = object : NSObject(), AVAudioPlayerDelegateProtocol
//or
player.delegate = MyOwnAudioPlayerDelegateImpl()
The problem is that the delegate is nullified at random times.
It works if I make the class containing the player extend AvAudioPlayerDelegateProtocol
and then do player.delegate = this
. But it's a bit ugly and creates different issues.
Does anyone know how I can manage memory reliably in the first scenario?Michal Klimczak
05/19/2021, 10:17 AM