• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strategy for NSTimer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Strategy for NSTimer (From: Tim Conkling <email@hidden>)

  • Prev by Date: Re: My bug or Apple's?
  • Next by Date: crossplatform C++, #ifdef
  • Previous by thread: Strategy for NSTimer
  • Next by thread: crossplatform C++, #ifdef
  • Index(es):
    • Date
    • Thread