AvAudioPlayer command for delegate in nil frees the delegate object?
@implementation MyClass
-(id) init
{
NSString *path0 = [ [NSBundle mainBundle] pathForResource:@"myfile" ofType:@"m4a" ];
mSound = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path0] error:NULL];
mSound.delegate = self;
}
-(void) release
{
mSound.delegate = nil; //<- this line causes MyClass release function to be called recursively
[ mSound release ]; //<- removing the line above makes this line do the same, i.e. calls myclass release recursively
}
It seems that freeing the AvAudioPlayer also frees the delegate object, I tried to trigger the save myself when assigning it to the delegate, but that didn't help.
even if I do something like:
-(id) init
{
NSString *path0 = [ [NSBundle mainBundle] pathForResource:@"myfile" ofType:@"m4a" ];
mSound = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path0] error:NULL];
mSound.delegate = self;
mSound.delegate = nil; //<- (just for test), causes MyClass release to be invoked,
}
I get freeing Myclass to be called immediately after initialization when I assign nil to the delegate
Any idea what's going on?
0
a source to share