NSTimer crashes after invalidation
NSTimer crashes after invalidation
- Subject: NSTimer crashes after invalidation
- From: Michael Becker <email@hidden>
- Date: Tue, 15 Feb 2005 01:43:21 +0100
Hi!
Here's the deal: I have an instance variable of type NSTimer. In an
instance method, I set up the timer via +scheduledTimer:... to fire
after 1 sec. So the instance variable should hold a reference to that
timer.
Now the method that sets up the timer can be called frequently within a
short amount of time, and I want to invalidate the timer if it hasn't
fired yet, and then set it up again. So the timer will only fire once
if the user gives it enough time, instead of firing once for each user
click, no matter how fast the user clicks.
Here is the code in my method that sets up the timer (it's in a
subclass of NSScrollView, if you care):
if (repaintTimer != nil) {
// This line crashes
[repaintTimer invalidate];
}
repaintTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f
target:[self documentView] selector:@selector(noLiveZoom) userInfo:nil
repeats:NO];
But it seems that if I call that method after the timer has once fired,
the indicated line crashes. The check for "repaintTimer != nil" will
ALWAYS give a YES, telling me that the repaintTimer variable is
"something" but not nil and obviously not an NSTimer, as sending any
kind of message to it will result in a crash.
What happens to my repaintTimer instance variable after the timer has
fired? How can I procrastinate the timer's execution in a correct way?
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