To basically only get the value from the slider we only need to make an outlet for the text field and an action for the slider. ( However if you want to set the slider by code you also need to make it an outlet also.)
The Slider action is as follows:
// field Outlet
@IBOutlet weak var fldSliderValue: NSTextField!
// NSSlider Action
@IBAction func mySlider1(sender: AnyObject) {
var x: Double = sender.doubleValue
// to get the value to display as text string in the field do this
var mystring = x.description
// display the value in the field
fldSliderValue.stringValue = mystring
}
Below is the source view:
Swift for Mac OS X is really fun. Will be sharing more soon.
No comments:
Post a Comment