[Solved] Re: NSTimer - crash when closing window
[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.