I am trying to make a custom button where I can implement my own functionality, like in the example below:
MSButton {
print("hello")
}
Problem is, I keep getting the Expression of type '(() -> Void)?' is unused
warning, and the functionality I add doesn't activate.
Here is the code I made in an attempt to implement this:
struct MSButton: View {
var action: (() -> Void)?
var body: some View {
Button() {
action // where I am getting the warning.
} label: {
Text("Button")
}
}
}
What am I missing that would allow me to get my action
to work properly? Any help would be greatly appreciated.