views:

13

answers:

1

I receive a crash on the call to the function set in setAnimationDidStopSelector when my view is animating as I remove the view and release the object. I'm not 100% certain that this is simply a case of a UIView animating while being released and the callback issued by the animation being called into a released object, but I suspect it has to do with some required cleanup.

Are there things I should be doing when cleaning up UIViews that may have a target selector for their animations, i.e. somehow setting the delegate to nil? If so, I'm not certain how to reach into that specific animation to cancel the delegate.

Are there other obvious potential causes to this crash? Basically, I kick off the animation and then shortly after I clean up and release the view animating as well as the object that is receiving the callback.

+1  A: 

probably not the solution, but did you call setAnimationDelegate as well? It should retain the delegate so your early release scenario shouldn't happen.

mvds
Thanks for the reminder that it's retained. Actually, the problem is that I'm moving on from my scene and cleaning up and I actually have an Adapter class that is used as the delegate. This class then calls into a C++ listener that handles the callback. When I clean up and release the obj-c adapter and shortly after clean up the C++ class, the retained adapter gets called with the animation stop and dutifully passes it on to the c++ class which is dead by now.I got things working by setting my Adapter's listener to nil when I clean up the C++ object. Not ideal possibly, but it works. :)
Joey
this then solves the mystery, right? you made it so that setAnimationDelegate didn't "retain" the effective c++ delegate.
mvds