Quantcast
Channel: How to convert a boolean expression to Binding in SwiftUI? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to convert a boolean expression to Binding in SwiftUI?

$
0
0

I have a textfield, and I am trying to goto another view when user input a specific string.

import SwiftUIstruct ContentView: View {    @State var whether_go = "No"    var body: some View {                    TextField("Goto?", text: $whether_go)                        .navigate(to: CircleImage(), when: whether_go == "Yes")    }}

This will raise error: Cannot convert value of type 'Bool' to expected argument type 'Binding<Bool>' Because when argument need a Binding<Bool>

I tried to use

when: Binding<Bool>(get: whether_happy == "Yes"))

This raise another error: No exact matches in call to initializer.

So what should I do to convert a boolean to Binding<Bool>?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images