Swift: Permanent Data Storage

In this tutorial, we will learn how to save permanently some data in our application. For data to be saved permanently in our application, we will need to use the "UserDefaults" command. Save a String permanently Let's save the name "Jack" as a the username for our last visitor in our application. To do that,... Continue Reading →

Advertisements

Swift: Functions

In this tuturial, we will learn how to create and call functions in Swift. Why do we use functions? We use functions for two main reasons: in order to break up the code into more manageable parts but also because we may need to use the same piece of code multiple times and a function... Continue Reading →

Swift: First application

After learning some basics in Swift, it is now time to apply what we have learned and create a little fun game. So, let's create a simple dice game between 2 friends, let's call them Zack and Andrew. The goal is to reach exactly 21. So the first one that will reach 21 will win the... Continue Reading →

Swift: Switch

Switch case Switch in Swift can be seen as a combination of if statements. Indeed, Swift takes the value of a variable or constant and then compares it to multiple cases until it founds the one that is true. Once it found the one, it will execute the code related to it and doesn't continue... Continue Reading →

Swift: While and Repeat-While

The while loop The while function will run until the condition that is tested becomes false, thus the loop can run one time or multiple times. It is well suited when we don't know how many times we should loop. So let's create a simple loop where we increment the numbers of steps by 2... Continue Reading →

Swift: For…in function

Another important function in Swift programming is "For". The goal of this function is to iterate over a range of numbers, characters in a strings or values in an array. So let's first use the "for" function in an array. Basically, we created a variable "pet" that will pick each value from the array "animals" and then... Continue Reading →

Swift: Arrays

Arrays are a very important and are used very often as data type in Swift. Arrays can be seen as a collection of values that are store into one single constant or variable. Creating an array is very simple in Swift, we simply separate all the values by commas and put them between square brackets.... Continue Reading →

Blog at WordPress.com.

Up ↑