NSAnimatablePropertyContainer and delegate

Christiaan Hofman <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
I need to use delegate methods for animations run through NSAnimatablePropertyContainer (-animator proxy) to know when the animation has finished. The main problem is CAAnimation's buggy behavior of retaining its delegate (I am aware it's as designed, but that only means it's a design bug).

So my basic question is: how am I supposed to use (set/unset) the delegate of an animation that's run behind the scene by the animator proxy?

Some observations.

To be able to set the delegate, I need to provide my own animation, probably through -setAnimations:, or otherwise by overriding -animationForKey:, because the default animation doesn't allow the delegate to be set for some reason (which I don't understand).

However, I can't just set the delegate for this custom animation, because that results in a retain cycle, and therefore a leak (that's why the behavior noted above is buggy). 

Therefore, I need to set the delegate temporarily, only during the animation. Unfortunately, NSAnimatablePropertyContainer does not expose anything like CALayer's -addAnimation:forKey: to run an animation only once and dispose of it afterwards. But this also means that I need to remove the delegate at an appropriate time. What time would that be? 

What makes it even more complicated is that the animation that's actually run is NOT the animation set in the -animations dictionary. It's apparently some copy. However, that copy is passed to the delegate method, rather than the animation on which I would set the delegate.

So, then how should I go about working around the retain cycle problem?

thanks,
Christiaan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.