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?
Asked
Active
Viewed 1,170 times
1 Answers
4
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.

Aaron Brager
- 65,323
- 19
- 161
- 287
-
Thanks Aaron, that was bugging the heck out of me not being able to find it. Not sure why you're not able to query it still. Maybe later versions will allow. I know that technically if I set it in Interface Builder then I can hard code its initial value, however I would really like to query it as you can query the value everything else. Guess I'll submit a feature request. Thanks! – justdan0227 Apr 12 '15 at 18:46
-
I assume it will come in a later version, but the API design is to reduce communications between the iPhone and the watch by forcing you to cache as much as possible on the iPhone side. – Aaron Brager Apr 12 '15 at 23:26
-
@AaronBrager sorry that doesnt make sense to me.. yes the action method will get triggered but how do you know if the user increased to decreased the value? therefore you won't always know the value? – 4GetFullOf Aug 13 '15 at 17:01
-
@4GetFullOf Read what I wrote: *"If you'll need to access it later, save the initial value in your data model and update it when the slider changes."* – Aaron Brager Aug 13 '15 at 23:48
-
@AaronBrager yes sorry I never noticed the action returns the value with every trigger – 4GetFullOf Aug 14 '15 at 14:25