• 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
-[NSTimer invalidate] does not guarantee that the timer won't fire?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-[NSTimer invalidate] does not guarantee that the timer won't fire?


  • Subject: -[NSTimer invalidate] does not guarantee that the timer won't fire?
  • From: Jim Correia <email@hidden>
  • Date: Tue, 17 Jan 2006 17:46:15 -0500

I have an object which owns an NSTimer, and the timer target is self.

In -dealloc I do

[timer invalidate];
[timer release];

If the object is deallocated while my app is in the foreground, all is well. If the object is deallocated while my application is in the background, the timer fires *after* dealloc has invalidated the timer, but the target (self) is now a zombie.

The documentation for -[NSTimer invalidate] says:
"This is the only way to remove a timer from an NSRunLoop. The NSRunLoop removes and releases the timer, either just before the invalidate method returns or at some later point."


Does this mean that there is no guaranteed way to ensure that a timer will never fire again when its target is going away? (Or is this simply a bug that I should write up.)

Thanks,

Jim


_______________________________________________ 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
  • Follow-Ups:
    • Re: -[NSTimer invalidate] does not guarantee that the timer won't fire?
      • From: Jim Correia <email@hidden>
  • Prev by Date: Re: Comparing pixels in an image
  • Next by Date: Does NSImage handle Icns Files?
  • Previous by thread: Re: Cocoa AppleScript question
  • Next by thread: Re: -[NSTimer invalidate] does not guarantee that the timer won't fire?
  • Index(es):
    • Date
    • Thread