From the course: Building Your First iOS 17 App

Unlock this course with a free trial

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

Understanding variables

Understanding variables

- [Instructor] Our next step with our Tip Calculator is to have the amount be user editable. And to do that, we have really two steps. The first one is to create something called a variable which is a value that can change at runtime and put that value inside of our text view. And the second is to make that text view into an editable text field. So let's start by creating this variable and I'm going to do that in between lines 10 and 11. So after line 10, I'll create a new line and then I'm going to type var which is the key word for creating a variable. It says, I'm going to create a variable after that var type a space, and then you're going to put the name of the variable, which in this case is total, and then we're going to set the value of the variable equal to something and that's going to be an empty string. If you're unfamiliar with programming a string is basically a text value, and we have a few of those here in…

Contents