I have a general problem using toggles with SwiftUI. Whenever I use them I get this console error:
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
In addition to this didSet does not print anything when I hit the toggle in the simulator. Does anyone have an idea, or is it a SwiftUI bug?
Other related questions on StackOverflow which are some month old didn't seem to find a solution.
import SwiftUI
struct ContentView: View {
@State private var notifyCheck = false {
didSet {
print("Toggle pushed!")
}
}
var body: some View {
Toggle(isOn: $notifyCheck) {
Text("Activate?")
}
}
}
If this is a bug, I wonder what the workaround for toggles is. It's not as if I would be the first person using toggles in iOS. ;-)