.toggle() function on bool does not call didSet. Is this a bug?
问题 I have a @State Bool variable with didSet on it. I want to do something when the variable change therefore I have tried to use didSet. The problem is when I use the .toggle() function to toggle the state of the bool, didSet is not called. Take this code for example: import SwiftUI struct SwiftUIView: View { @State var testBool = false { didSet { print("set") } } var body: some View { VStack { Button(action: { self.testBool.toggle() }) { Text("Toggle with .toggle()") } Button(action: { if self