Xcode 11.3 (11C29).
macOS 10.15.2.
In the SwiftUI View below there are two buttons. One prints "OK" and the other prints "Cancel". However, regardless of whichever button is pressed, both print statements are executed. Why is that? (I assume it must be a SwiftUI bug.)
struct ContentView: View {
var body: some View {
List {
HStack {
Button("OK") {
print("OK.")
}
Button("Cancel") {
print("Cancel")
}
}
}
}
}
(If either the List
or the HStack
is commented out then each button only prints its own statement.)