๐Ÿ”ฐBinding State

SwiftUI โŸฉ Data Flow โŸฉ Binding โŸฉ create Binding from State

๐Ÿ“— ๅƒ่€ƒ๏ผšSwiftOnTap โŸฉ Binding โญ๏ธ

// โญ๏ธ creating `Binding` from `@State`
struct ExampleView: View {

    // โญ๏ธ source of truth: @State variable
    @State private var text: String = "๐ŸŒ๐ŸŒ"

    var body: some View {
        // text: String 
        Text(text)
        // โญ๏ธ $text: Binding<String>
        // two-way connection to a source of truth
        //                             โ•ญโ”€โญ๏ธโ”€โ•ฎ
        TextField("Placeholder", text: $text)
    }
}

Last updated