Re: NSAnimatablePropertyContainer and delegate
"Adam R. Maxwell" <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Dec 20, 2009, at 2:44 PM, Christiaan Hofman wrote: > 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). Could you set the delegate to an proxy object that the animation retains, but which doesn't retain your real delegate? You could then use forwardingTargetForSelector: to forward messages. I don't have a suggestion for any of your other questions; I've avoided using -animator as much as possible because of other bugs we've previously discussed.