NSCombobox, NSTimer
-
24-01-2021 - |
Question
I have the code for timer with time interval 5 seconds. Is there an easy way to control the time interval with NSCombobox or something similar? Let's say: I would like to choose the timer interval from 1 to 5 seconds in the Combo Box.
[NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(updateTextFieldWithRandomNumber)
userInfo:nil
repeats:YES];
Solution
You can get doubleValue
from any NSControl
subclass:
[NSTimer scheduledTimerWithTimeInterval:[myComboBox doubleValue]
target:self
selector:@selector(updateTextFieldWithRandomNumber)
userInfo:nil
repeats:YES];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow