Re: Unwanted retain
Re: Unwanted retain
- Subject: Re: Unwanted retain
- From: Dustin Voss <email@hidden>
- Date: Wed, 4 Feb 2004 17:55:31 -0800
On 4 Feb, 2004, at 4:46 PM, Lorenzo wrote:
Hi,
thank to everybody.
Thanks for explaining so well the timer retains the target object.
My error was that I released the timer within the dealloc object
method.
This way:
- (void)dealloc
{
if(renderTimer){
[renderTimer invalidate];
[renderTimer release];
renderTimer = nil;
}
[super autorelease];
}
So when my superclass released my object, the object could have not
been
deallocated properly.
Now I relase the timer using a different method like
[myObject relaseTimer];
[myObject release];
You still have the wrong idea. First, when an object is deallocated, it
is NOT released from NSObject down. NSObject's dealloc method is the
last one to get called. So it is not the superclass that deallocates
your class, but rather it has to be your class that deallocates the
superclass.
You do this by calling [super dealloc]. Don't call [super autorelease].
Also, do not call [renderTimer release]. [renderTimer invalidate] will
take care of that for you. The documentation does not make this clear,
though it should.
If you do this, I think you'll find that you don't need a separate
releaseTimer method.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.