Re: Unwanted retain
Re: Unwanted retain
- Subject: Re: Unwanted retain
- From: Andreas Mayer <email@hidden>
- Date: Thu, 5 Feb 2004 00:12:43 +0100
Am 04.02.2004 um 23:41 schrieb Lorenzo:
I noted that when I call scheduledTimerWithTimeInterval, my self object
retainCounter increments by one.
Since you tell the timer to send a message to your object referenced by
'self', the times makes sure said object will be still alive when it is
actually time to send that message by retainmng it.
Then if I deallocate one time only the object "self" from the class I
created it
You mean, when you _release_ it. You are not supposed to send dealloc
to any object (besides super in your own dealloc method).
I don't see the object self deallocated.
Of course not. It's still retained by the timer.
I have to deallocate it
twice, but then my app crashes.
Sure. If you deallocate it the timer will try to send a message to a
non-existant object which will crash your app.
Do you know how to fix this?
Invalidate the timer first:
[renderTimer invalidate];
From the documentation:
"- (void)invalidate
Stops the receiver from ever firing again and removes it from any run
loops. This is the only way to remove a timer from an NSRunLoop.
The receiver releases its references to the target and userInfo objects
at this point."
bye. Andreas.
_______________________________________________
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.