15

Is there a way to make an IBOutlet of an NSSlider and then be able to change its value programmatically? slider.value = ...does not work.

Thanks!

Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
Grant Wilkinson
  • 1,088
  • 1
  • 13
  • 38
  • Couldn't get it to work for the IBOutlet of an NSSlider, however the IBOutlet of the NSSlider's NSSliderCell worked as expected. – Pierre Dufresne Jul 10 '21 at 01:42

3 Answers3

22

You can use the methods of NSControl.

Example: [self.slider setDoubleValue:0.1];

Schulze Thomas
  • 465
  • 3
  • 10
9

Swift answer to this question is to use the doubleValue property to access the slider value in OSX:

slider.doubleValue = 0.1 

print(slider.doubleValue)
Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
0

As of 2021, using setDouble on NSSlider does not work. Instead, in interface builder select the NSSliderCell child of the NSSlider and use the NSSliderCell's IBOutlet. On the program side, either setFloat or setDouble will work.

Pierre Dufresne
  • 166
  • 1
  • 6