From the course: SwiftUI Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Text input

Text input

- [Instructor] We've so far looked at constrained interaction but there's interaction that the user will be entering less constrained information like text. There are two views you should know about to handle text. Each for a specific purpose. Text fields and text editors. Okay, so we're going to add in two state variables for this. So first one we're going to do is @State private var name string equals double quotes and we'll do the same thing again. State private var comments and that'll be a string. Again, we'll just use a blank string to start. Okay. And so we have two strings here. And then on the top of the VStack I'm going to put my first one which is going to be my text field, okay? And text fields are for shorter single line responses that of a prompt. For example, we'll add a name field so that we know whose pizza is which on a large order. So fields have two parameters, a prompt or place maker string…

Contents