Reputation: 183
I have a NSTimer and a NSSlider in my app. How do I make, that the time interval of the timer would respond instantly to the slider value?
For now it responds just at the beginning. Once the timer is already fired, it doesn't respond any more...
[NSTimer scheduledTimerWithTimeInterval:[slider doubleValue]
target:self
selector:@selector(updateTextFieldWithRandomNumber)
userInfo:nil
repeats:YES];
Upvotes: 0
Views: 225
Reputation: 86651
What about putting a KVO observation on the slider's doubleValue
property and invalidating the timer and recreating it when the notification happens?
Upvotes: 0
Reputation: 135548
You cannot change the time interval of a timer once you have created it. You have to invalidate the old timer and create a new one with the new time interval.
Upvotes: 1