From the course: Programming for Non-Programmers with iOS 9 and Swift

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Using conditional statements

Using conditional statements - iOS Tutorial

From the course: Programming for Non-Programmers with iOS 9 and Swift

Start my 1-month free trial

Using conditional statements

- So let's get some practice using conditional statements. We'll start in Main.storyboard and just drag a label onto the screen. So I'm going to search for a label in the Object Library and drag it onto the screen and then I'm going to connect this to our View Controller class. So first, I'll extend it a little bit to the right and then opt + click ViewController.swift and there it is on the right and now, I'll hide the Utilities area and Document Library to get some more space. And then, just right click and drag from the label into my code, in between lines 12 and 13. I'll call this label, click Connect, and there is my property. So I'll return to the standard view and go back to ViewController.swift. So we have our label here and inside of viewDidLoad, right under the comment, I'm going to write our if statement. In Swift, the parentheses for an if statement are optional. I usually put them anyway just because it's easier for me to read but you don't have to if you don't want to…

Contents