I have a state variable of a struct with 2 numbers. I have a selection box for the 1st one, and a selection box for the 2nd one which should cap it at the 1st one. I implemented the capping logic with didSet. The value of the selections did change, but not the text that display the selected value for the 2nd one. Here’s the pseudo code. Any idea?
struct CustomTaskView: View {
@State private var options: MyClass {
didSet {
if options.a > options.b {
options.a = options.b
}
}
}
var body: some View {
// selection box for options.a
// selection box for options.b
// ...
Text("(options.a)")
Text("(options.b)")
}
}
1