PDA

View Full Version : if(![object FREED]){




cwolves
Apr 21, 2009, 11:46 PM
I have an object that is released in the middle of doing something. Specifically, it's an animation. When it changes to a frame, an event gets called via an NSNotification, and the subscriber sometimes releases the object.

The issue I'm running into is that after the object is released, control passes back to the object. It then calls [super render] which renders another frame of the animation.

If I check self at any point after the release, I get a type of "FREED(ID) *", with all the data still intact.

So my question is, is there a "correct" way of saying "only call [super render] if I still exist"?

btw "if(self){" doesn't work. :D



eddietr
Apr 21, 2009, 11:58 PM
The issue I'm running into is that after the object is released, control passes back to the object.

Personally, I would say that is a bug. I would rethink your design on this.

neoserver
Apr 22, 2009, 08:32 AM
I don't believe there is a method that you can send to a released object (which based on what i understand of your problem, would not exist anymore) to see if it exists. Either the object exists and it works, or it doesn't and you get an exec_bad_access. like eddietr, I'd take a look at your design and fix it up that way.