4 ms·
I don’t write swift, but didn’t you miss a comma and a label for your Text(“Hit me to toggle”) argument in your second example? Did you mean: Button(action:
by willyt 5y ago
I don’t write swift, but didn’t you miss a comma and a label for your Text(“Hit me to toggle”) argument in your second example? Did you mean:
Button(action: self.isWarningEnabled.toggle, label:{
Text("Hit me to toggle")
})
Not sure if you can just pass the method signature and omit the parentheses so it doesn’t get called like you can in python. Would be interested to know.
- deergomoo 5y ago> I don’t write swift, but didn’t you miss a comma and a label Swift has a feature called "trailing closures". If the last argument to a function is a closure, you can close the brackets early and put the closure directly after.