Hi together,
i have a Binding in my SwiftUI View. It looks like this:
struct ContentView: View {
var body: some View {
let binding = Binding<String>(get: { () -> String in
return String(format: "%.2f", self.model.value)
}) { (s) in
var s = s
s.removeAll { (c) -> Bool in
!c.isNumber
}
self.model.txt = s
}
VStack{
TextField("Amount", text: binding)
Button(action: {
loading = true
AF.request("https://example.com/\(binding)", method: .get)
.responseString{response in
// ...
}
}){
Text("Go")
}
}
}
}
But I can't use the binding in my Interpolation - it crashes instantly when this AF Request code runs!
Can I "refactor" the binding to a default var?
Can anyone help me?
Thanks!