Re: NSTimer crashes after invalidation
Re: NSTimer crashes after invalidation
- Subject: Re: NSTimer crashes after invalidation
- From: Daniel Jalkut <email@hidden>
- Date: Tue, 15 Feb 2005 14:38:46 -0800
On Feb 15, 2005, at 4:02 AM, Rosyna wrote:
And once it is retained, replace the repaintTimer!= nil with
[repaintTimer isValid]
... and then release it!
Better to just take out the invalidation altogether, and don't bother
retaining it. Don't even bother saving the repaintTimer variable.
What's it needed for? No need to invalidate a fire-once timer, it's
done for you. And no need to release it, because it was retained and
released by the runloop.
Daniel
Ack, at 2/15/05, M. Uli Kusterer said:
At 1:43 Uhr +0100 15.02.2005, Michael Becker wrote:
if (repaintTimer != nil) {
// This line crashes
[repaintTimer invalidate];
}
repaintTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f
target:[self documentView] selector:@selector(noLiveZoom)
userInfo:nil repeats:NO];
You need to retain the timer. Fire-once timers automatically
invalidate themselves once they have fired, and if you don't retain
the timer, that means it'll be released, and you'll have a stale
pointer lying around in your instance variable.
--
Sincerely,
Rosyna Keller
Technical Support/Holy Knight/Always needs a hug
Unsanity: Unsane Tools for Insanely Great People
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
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