I'm having some problems concerning memory management with a CAAnimation delegate. I add an animation to an image view on screem with the following code:
The animation retains its delegate, the ship. In animationDidStop:Finished: I try to set the delegate to nil so my ship will be properly released, but it says that the animation is readonly and I cannot change the delegate. How can I make it so the animation will release its delegate?
Code:
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim.fromValue = [NSValue valueWithCGPoint:aShip.center];
anim.toValue = [NSValue valueWithCGPoint:aPlanet.center];
anim.duration = time;
anim.delegate = aShip;
anim.removedOnCompletion = YES;
[aShip.layer addAnimation:anim forKey:@"fly"];
The animation retains its delegate, the ship. In animationDidStop:Finished: I try to set the delegate to nil so my ship will be properly released, but it says that the animation is readonly and I cannot change the delegate. How can I make it so the animation will release its delegate?