From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

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

Toggles and steppers

Toggles and steppers

- [Instructor] We've learned the basics of data and how to present information. Now it's time to get users to interact with the system using controls. Controls use binding variables to read and write values to the control. I'll start by looking at two simple controls, then get more complicated, but we're going to do this in a new view. So let's make a new SwiftUI view. So let's go into our code here and do a Command + N, do a SwiftUI View, make sure all of our things are right, which they are. And then I'm going to go up here and put in OrderItemView, and create that. I'm going to make a couple of variables here that we're going to be using. So we're going to start with a Binding, orderItem, and that will be of OrderItem. We'll do a State, which will be quantity, and another State, which will be for doubleIngredient. We will make that a bool that's false. Okay, so we've got this now in place. And I forgot a var up there, so let's put that in. And then, of course, we've got our…

Contents