Category: Swift Programming
-
More if{}else{}
Edited Transcript Last time we learned the if-else, Let’s expand on that knowledge with more about if-else.In our code so far, we have several nested comparisons. Each makes only one comparison. What if I wanted to look at two conditions, not one? For example, what if pizzas of sizes 14 to 18 were marked on…
-
Make Swift Playground Apps: Using if{}else{}
Transcript Up to now, we’ve assigned constants and variables directly. Our next step is to change them when conditions change. For that, we use the if-else construct.Let’s go back to the playground. Change the assignments on the bottom to: Add a boolean variable underneath The if statement takes a boolean value. If true, the…
-
Make Swift Playgrounds Apps : Variables and Scope
Transcript We’ve been using constants and literal up to now. However, you will want values to change as you build apps. For that, you need variables. Let’s look at variables and how to use them. We’ll start with the same code from the last lesson. Try adding to the bottom of the code You’ll get…
-
Make Swift Playgrounds Apps: Learn About Swift Types
We’ve used integers and strings so far in our code for values. We use each differently, and their use we call a type. Numbers like integers are a type, as are strings as text. Swift is a strongly typed language. To best use Swift, you need to understand the basic types. We’re going to use…
-
Make Swift Playgrounds Apps: Adding Images
Transcript We’ve made our basic wireframe, now let’s begin to add more content. The images we have now wont tell us a much as true images. So we’ll load some images into the icon , the header and the menu items using two placeholders. You’ll find like to the photos here and here. Download them…
-
Make Swift Playgrounds Apps: Create New Files and Views
Transcript We have the wireframe for the menu page of our takeout order app, but we have only one menu Item, and we probably want more than that. How can we get more items? Let’s find out. Swift and SwiftUI are a modular language. You build small pieces that do one thing and then and…
-
Make Swift Playgrounds Apps: HStack, VStack and Layout
Transcript We’ve learned some basics of Swift and some fundamental SwiftUI objects. Unfortunately what we’ve done as a demo doesn’t look so nice. So let’s get together the beginnings of a fun app to order pizza! I’ll start by closing our current app. Then I’ll make a new app. I’ll pop out for a second…
-
Make Swift Playgrounds Apps: Using Functions
Transcript We have Identifiers for values we can use repeatedly. If you think of constants as nouns we’ll need some verbs to do actions. Swift has actions we can use repeatedly. We call these functions. Here’s a simple example. Add this to your code just below the thing2 declaration. This is a function. A…
-
Make Playgrounds Apps: Constants and Calculations
Transcript We’ve got an application started, but it is very hard to change to do anything with. If I wanted something other than guitars, such as a lightbulb or tv, I’d have to change the entire program. Swift playgrounds and its bigger brother on the Mac, Xcode, have special programs called compilers and interpreters. These…