質問

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