From the course: iOS 17 Development Essential Training

Unlock this course with a free trial

Join today to access over 24,000 courses taught by industry experts.

Getting text input with SwiftUI

Getting text input with SwiftUI

- [Instructor] As we move forward with SwiftUI, the next concept that we're going to talk about is working with something called binding. And that has to do with how variables work inside of SwiftUI. For example, if you want to get a value from a text field and use it inside of a text view, like we did with storyboards earlier in the course. So let's start by using a regular variable. So just below struct ContentView, I'm going to create a new line and we'll call this hello and this will be equal to the string, so I'll put some double quotes. Hello world, just like that. So we have our variable and now we can use it inside of a text view. So if I replace Weather and its quotes with Hello, then I get that message inside of the text view on the screen. What if instead of getting the value from a variable for this text, or rather directly from a variable, we got the value from whatever input was typed by the user? So…

Contents