Swift: The Basics - Swift Academy: The Stress Free Way To Learning Swift Inside & Out (2014)

Swift Academy: The Stress Free Way To Learning Swift Inside & Out (2014)

Chapter 1. Swift: The Basics

What is Swift?

Swift is a computer language that can help you create OS X and iOS apps. Apple Inc., one of the largest names in the IT world, launched this language just a few years ago. You don’t have to worry if you have never created apps for Apple machines before. Swift shares many of its characteristics with two popular programming languages: C and Objective-C.

The Swift language uses the fundamental data types (e.g. Boolean, floating-point, strings, etc.) of C and Objective-C. Additionally, it offers powerful variants of two major data collection types: Dictionary and Array.

How Does Swift Work?

Similar to the C language, Swift stores values into variables and retrieves them using an identifier. Also, Swift makes use of objects with unchangeable values (known as “constants”). Programmers claim that constants in Swift are much more powerful than those of other programming languages. By using Swift constants, you can improve the clarity and cleanliness of your codes.

Aside from the fundamental data types, Swift possesses advanced types that are not available in other languages. A great example is the “tuple,” a data type that allows you to generate and share value groups. A tuple can also generate a single compound value from a group of values.

This language also introduces a data type called “Optionals.”Basically, Optionals say either “no value exists” or “a value exists, and it is equal to x.” Optionals have some similarities with nil pointers in the Objective-C language. The main difference between these types is that Optionals can work on any data type. Because of this, Optionals are better than nil pointers in terms of safety and expressiveness. You should learn how to use Optionals since they play an important role in most of Swift’s programming capabilities.