• 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: Memory Management Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management Question


  • Subject: Re: Memory Management Question
  • From: "Daniel T. Staal" <email@hidden>
  • Date: Tue, 3 Jul 2007 13:52:28 -0400 (EDT)
  • Importance: Normal

On Tue, July 3, 2007 1:13 pm, Seth Pellegrino said:

> Mainly my problem is with the NSTimer class. Whenever the user clicks
> pause in my application, I call -[invalidate] to stop the timer from
> firing (as there seems to be no -[pause] or similar). However, this
> causes the run loop to release the timer, so whenever I try to call -
> [isValid], my program crashes. As I type this, I realize that I
> should be also -[retain]ing my instance of the NSTimer class, but if
> I do so, is there a way to make an invalidated timer resume firing?
> Or would it be better to just use a BOOL isPaused and an if statement?

I don't see any way to make a timer resume firing.  The standard way to do
this is probably to invalidate the timer on 'pause' and start up a new
timer on 'unpause'.  (So they are actually 'stop' and 'start', behind the
scenes...)  The if-isPaused would also work.

Take a look at the NSAnimation class as well: In a lot of repects is it
just a fancy timer, and it does have pause and restart capablity.

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Memory Management Question (From: Seth Pellegrino <email@hidden>)
 >Re: Memory Management Question (From: "Daniel T. Staal" <email@hidden>)
 >Re: Memory Management Question (From: Seth Pellegrino <email@hidden>)

  • Prev by Date: Re: NSPopupButton in main window changes when NSUserDefaultsController adds/removes item in Preference Pane
  • Next by Date: Re: Cocoa and dead-code stripping
  • Previous by thread: Re: Memory Management Question
  • Next by thread: Re: Memory Management Question
  • Index(es):
    • Date
    • Thread