Вопрос

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];
Это было полезно?

Решение

You can get doubleValue from any NSControl subclass:

[NSTimer scheduledTimerWithTimeInterval:[myComboBox doubleValue]
                                 target:self
                               selector:@selector(updateTextFieldWithRandomNumber)
                               userInfo:nil
                                repeats:YES];
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top