[Swift UI] Apple Watch App
How to use set didSet instead of Binding
PROPERTY
@AppStorage("lineCount") var lineCount: Int = 1
@State private var value: Float = 1.0
BODY
Slider(value: $value, in: 1...4, step: 1)
.accentColor(.accentColor)
Change to
// SLIDER
Slider(value: Binding(get: {
self.value
}, set: {(newValue) in
self.value = newValue
self.update()
}), in: 1...4, step: 1)
.accentColor(.accentColor)
---
func update() {
lineCount = Int(value)
}