Re: Unwanted retain
Re: Unwanted retain
- Subject: Re: Unwanted retain
- From: Ryan Bates <email@hidden>
- Date: Thu, 5 Feb 2004 17:05:50 -0800
On 5 Feb, 2004, at 9:27 AM, b.bum wrote:
While Clark might be correct, it is completely and totally irrelevant
to consider what the run loop might or might not be doing to the
retain count of the timer. Reading the documentation for NSTimer and
NSRunLoop, neither mention anything about retaining the timer. While
the Run Loop might retain the timer for its own purposes, that is none
of your business as a Cocoa developer! :-)
While I agree it is irrelevant, the Apple docs do say the run loop
retains the timer:
"Note that run loops retain their timers, so you can release the timer
after you have added it to a run loop."
<
http://developer.apple.com/documentation/Cocoa/Conceptual/Timers/
Tasks/createtimer.html>
Here are a couple of rules that might help everyone with NSTimers (and
hopefully won't cause extra confusion):
- A timer retains the target and userInfo objects.
- A timer is automatically retained by the run loop when scheduling it.
- If a timer is not set to repeat, it will automatically invalidate
itself upon firing.
- A timer is released from the run loop when calling invalidate.
- A timer releases the target and userInfo objects when calling
invalidate.
Ryan Bates
_______________________________________________
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.