A quick written example based on an array with the required values:
SampleAppDelegate.h
SampleAppDelegate.h
#import "SampleAppDelegate.h" @implementation SampleAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { values = [[NSArray alloc] initWithObjects:@"0",@"1",@"2",@"10",@"50",nil]; [theSlider setNumberOfTickMarks:[values count]]; [theSlider setMinValue:0]; [theSlider setMaxValue:[values count]-1]; [theSlider setAllowsTickMarkValuesOnly:YES]; [theLabel setStringValue:[values objectAtIndex:0]]; [theSlider setIntValue:0]; } - (IBAction)sliderChanged:(id)sender { int current = lroundf([theSlider floatValue]); [theLabel setStringValue:[values objectAtIndex:current]]; } @end
Builder Interface:
- Add NSSlider (connect IBOutlet / connect IBAction / enable continuous update)
- Add NSTextField (connect IBOutlet)
Result:

source share