0

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];
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
Damijan
  • 183
  • 1
  • 2
  • 7

1 Answers1

1

You can get doubleValue from any NSControl subclass:

[NSTimer scheduledTimerWithTimeInterval:[myComboBox doubleValue]
                                 target:self
                               selector:@selector(updateTextFieldWithRandomNumber)
                               userInfo:nil
                                repeats:YES];
Carl Norum
  • 219,201
  • 40
  • 422
  • 469