## For Loops

In Swift, you can use a for loop to repeat code. For example, let’s use a for loop to calculate the sum from 0 to 10: Output: Loops are extremely common in Swift and other programming languages. As you can imagine, when working with data, you need to be able to repeatedly perform the same …

## Switch Statement

In Swift, you can use the switch statement to turn lengthy if-else statements into more concise and structured expressions. For example, take a look at this if-else statement. There is a lot of repetition and the code is quite long and somewhat verbose. In this case, you can tidy up the code by replacing the …

## If-Else Statements

In Swift, you can use an if-else statement to let your program make decisions. For example, let’s check if a person can drive based on their age: This results in the following output in the console: If-else statements are everywhere. They are the basic building blocks of programming. With if-else statements, you can start implementing …

## Logical Operators

In Swift, there are three logical operators: &&, ||, and !. Here is a table that describes these operators: Operator Name Description Example && Logical AND operator. If and only if both the operands are true, the condition is true. true && false = false || Logical OR Operator. If either one of the two …

## Comparison Operators

In Swift, you can compare values using the comparison operators, such as the greater-than operator. For example, let’s check if 1 is less than 2: Output: Here is a table of all the comparison operators in Swift: Operator Name Description == equals Checks if two values are equal to one another. != not equal Checks …

## Math Operators

In this chapter, you are going to learn the basic math operators in Swift. The four common math operators in Swift are: + for addition. – for subtraction. * for multiplication. / for division. For example, let’s perform some basic maths with these operators and store the results into variables: In this guide, you are …

## Data Types

In Swift, each variable/constant holds a value that represents some data type. There are lots of data types in Swift. As a beginner, it is important to learn these 5 basic data types first: Int to store whole numbers. String to store words. Double and Float to store decimal numbers. Bool to store the truth …

## Variables and Constants

In Swift, a variable represents a value that can be changed later on. The idea of a variable in programming is the same as variables in math. To create a variable in Swift, use the var keyword. For instance, let’s create an integer variable that represents the number 10: A constant is a value that …

## Setting Up the Xcode Editor

To create an iOS app, you need to install an app called Xcode on your Mac. Xcode is a code editor where you write your iOS programs and run them. In this chapter, you are going to learn how to install Xcode, create a program file, and run the program. Because this is a beginner-level …

## Introduction to iOS Development

So you want to become an iOS developer? It is a great choice! Developing iOS apps is an in-demand skill that is still definitely worth learning and is going to be such for a long time. However, building apps takes a lot of time. Probably a lot more than you thought. An integral part of …