SwiftUI Binding with Functions

struct ContentView: View {

@State var text = “Lorem Ipsum”

var body: some View {
TextEditor(text: Binding(get: /*() -> Value*/, set: /*(Value) -> Void)*/)
}

}

The get function will access the text to display it:

f…


This content originally appeared on DEV Community and was authored by Mateus Rodrigues

struct ContentView: View {

    @State var text = "Lorem Ipsum"

    var body: some View {
        TextEditor(text: Binding(get: /*() -> Value*/, set: /*(Value) -> Void)*/)
    }

}

The get function will access the text to display it:

func getText() -> String {
    return text
}

The set function will update the text when the user change it:

func setText(_ value: String) {
    text = value
}


This content originally appeared on DEV Community and was authored by Mateus Rodrigues


Print Share Comment Cite Upload Translate Updates
APA

Mateus Rodrigues | Sciencx (2024-06-24T20:10:24+00:00) SwiftUI Binding with Functions. Retrieved from https://www.scien.cx/2024/06/24/swiftui-binding-with-functions/

MLA
" » SwiftUI Binding with Functions." Mateus Rodrigues | Sciencx - Monday June 24, 2024, https://www.scien.cx/2024/06/24/swiftui-binding-with-functions/
HARVARD
Mateus Rodrigues | Sciencx Monday June 24, 2024 » SwiftUI Binding with Functions., viewed ,<https://www.scien.cx/2024/06/24/swiftui-binding-with-functions/>
VANCOUVER
Mateus Rodrigues | Sciencx - » SwiftUI Binding with Functions. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/24/swiftui-binding-with-functions/
CHICAGO
" » SwiftUI Binding with Functions." Mateus Rodrigues | Sciencx - Accessed . https://www.scien.cx/2024/06/24/swiftui-binding-with-functions/
IEEE
" » SwiftUI Binding with Functions." Mateus Rodrigues | Sciencx [Online]. Available: https://www.scien.cx/2024/06/24/swiftui-binding-with-functions/. [Accessed: ]
rf:citation
» SwiftUI Binding with Functions | Mateus Rodrigues | Sciencx | https://www.scien.cx/2024/06/24/swiftui-binding-with-functions/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.