I'm trying to use this function:
var handler: (String, (Bool) -> Void) -> Void
And the error displayed in the preview provider is that there's a missing argument for the parameter in call, but I don't know how to do that properly.
Insert ', handler: <#(String, (Bool) -> Void) -> Void#>'
If you have some documentation or explanation about handling these types of data in the preview provider I'd be really grateful.
This is a little tricky because of the closure-within-a-closure. Xcode doesn't seem to want to inline the second closure, but assuming it's defined outside of it, it seems to work fine:
struct MyView : View {
var handler: (String, (Bool) -> Void) -> Void
var body: some View {
Text("Hello, world")
}
}
struct TestView_Preview : PreviewProvider {
static var boolHander : (Bool) -> Void = { _ in }
static var previews: some View {
MyView(handler:{ myString, boolHander in })
}
}
I'm making some assumptions here, since you didn't actually include any code showing where/how it was defined, but hopefully this gets you moving in the right direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With