Search code examples
iosswiftapple-watch

How do you query the current value of WKInterfaceSlider in Swift


How do you get the current value of a WKInterfaceSlider in Swift? I can't find it in the docs anywhere? I can get the value when the slider is changed, however how to I query its state upon initialization?


Solution

  • Like many WatchKit objects, to save battery life, this object doesn't allow you to get values.

    Since you set the initial value (either with setValue(_:) or in your storyboard), and you're informed in the action method when it changes, you should always know it.

    If you'll need to access it later, save the initial value in your data model and update it when the slider changes.