Re: Strategy for NSTimer
Re: Strategy for NSTimer
- Subject: Re: Strategy for NSTimer
- From: Daniel Todd Currie <email@hidden>
- Date: Thu, 11 Nov 2004 20:36:43 -0800
On 2004 Nov 11, at 19:42, Tim Conkling wrote:
I have a situation where I require an NSTimer that occasionally needs
to be firing, but usually does not.
Currently, I am simply creating a new timer with
+scheduledTimerWithTimeInterval... every time I need it, and then
-invalidate'ing it when I'm done. Does this leak memory (I am not
retaining the timer after creating it)?
As far as I have seen, class methods always return autoreleased
objects. If you didn't alloc it, you don't need to release it.
Also, would a better strategy for this situation be to create a timer
once, and turn it on and off (with -setFireDate:?) as needed, or
should I stick to my current method of doing things?
The tradeoff is the processing time of creating a new timer every time
you need it, versus having the timer always taking up space in the
stack. I can't imagine either case having a significant impact on
performance.
Thanks,
Tim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden