Frage

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];
War es hilfreich?

Lösung

What about putting a KVO observation on the slider's doubleValue property and invalidating the timer and recreating it when the notification happens?

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top