Re: NSTimer crashes after invalidation
Re: NSTimer crashes after invalidation
- Subject: Re: NSTimer crashes after invalidation
- From: Michael Becker <email@hidden>
- Date: Wed, 16 Feb 2005 00:55:00 +0100
Am 15.02.2005 um 23:38 schrieb Daniel Jalkut:
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.
Here's the scenario: The user operates an NSSlider. Now whenever the
slider has been moved, an NSTimer is triggered to perform a certain
(lengthy) operation. When the user drags the slider, there will be many
timers triggered (the slider is set to continuously send action
messages).
Here is my plan: To avoid the many timers, I set the timer to fire in
0.2 secs. In my action method, I need to check if a timer is currently
triggered. If that is the case, I invalidate that timer and set a new
one up. This way, I can make sure that the timer fires only once after
the user dragged the slider.
Sounds a little confusing (even to me, now). But it works. And that's
why I need to keep a variable to the timer -- I want to check it and
maybe invalidate it BEFORE it fired.
Regards,
Michael
_______________________________________________
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