• 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
[Solved] Re: NSTimer - crash when closing window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Solved] Re: NSTimer - crash when closing window


  • Subject: [Solved] Re: NSTimer - crash when closing window
  • From: Jens Bauer <email@hidden>
  • Date: Sat, 11 Oct 2003 14:37:41 +0200

Hi all,

My crashes disappeared when I moved the removeObserver from -timerStop to -dealloc, as shown below.
-windowWillClose: was not invoked, due to that I removed the observer too early (even multiple times, argh!), and therefore -dealloc wasn't called either.
...So the solution is... Don't invoke removeObserver, until you don't need it anymore. ;)

Thanks to Alastair Houghton and Thomas Schnitzer for the quick help! I appreciate it very much!


- (void)timerStop
{
if(timer)
{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
[timer invalidate];
[timer release];
timer = NULL;
}
}

- (void)dealloc
{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
[self timerStop];
[super dealloc];
}


Love,
Jens
_______________________________________________
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.

References: 
 >Re: NSTimer - crash when closing window (From: "Alastair J.Houghton" <email@hidden>)

  • Prev by Date: Re: NSTimer - crash when closing window
  • Next by Date: update displayed Text
  • Previous by thread: Re: NSTimer - crash when closing window
  • Next by thread: update displayed Text
  • Index(es):
    • Date
    • Thread