The idea here is that a label would float up and fade out and then be removed. The problem lies in that if the object is deleted before the sequence is through, the CCCallFuncN will cause a crash.
What is the proper way to run an animation sequence and have the node be removed from the stage upon completion? Or even just a safer way to say call this function IF the object still exists?
I think your code should work fine, I did similar things and it worked without a problem.
If the CCCallFuncN is the one crashing, maybe you can call retain on it, so the reference count won’t be zero, and later release it.
I sometimes get crashes like this:
In your experience, if you retain before calling the sequence and release or autorelease in the callback, should this be avoided?
I have a similar problem. In mi case I have a class which manages a CCSprite where the animation is executed. And the callback method is defined in the class “ContainerClass” following the example above.
The problem is that when I destroy ContainerClass I call stopAllActions() for the CCSprite. But the error keep appearing. Stoping all the actions is not enought.
What can I do? I need to destroy this object (ContainerClass) before the CCSprite which is managed by a superclass. But in seconds the CCSprite will be destroyed by the superclass destroy method.