Introducing Swift and Playgrounds

What is Swift?

Swift is unique programming language developed by Apple. It draws upon many influences and comes with its own unique syntax, formatting best-practices, and ideologies. It introduces a lot of new concepts that were not present in Objective-C (Apple's previous programming language).

It is not simply a framework on top of, or a sub-set of Objective-C, but an entirely new programming language created as Apple attempts to join the trend to move away from C-based languages for high-level development.

Some of the features of Swift include: inferred types, automatic memory management, and expressive code.

What is a Playground?

A playground is a "sandbox" environment built into Xcode that allows you to see the results of your code in real time. We will be using Playgrounds to learn Swift.

NOTE

You can't develop a full application in a playground — it is for testing only.

How to Create a Playground?

The Xcode interface gets updated from time to time. If you would like to create a new Playground in the current version of Xcode You can choose one of three ways. The first way is from the Xcode splash screen shown when you launch the Xcode application.

create a swift playground

You can click the first option "Get started with a playground".

The second way to create a new Playground is by the Xcode menu at the top of your screen.

alternate method to create playground

The third option for creating a new Playground is the keyboard shortcut ⌥⇧⌘N.

After that you will be prompted to choose a template.

alternate method to create playground

We will be using a basic blank iOS template for our Playgrounds.

The next step is to give the new Playground a name and choose a location to save the file.

save playground

NOTE

These steps might look slightly different in older versions of the Xcode.

After you click to create your new Playground it will be opened and displayed in the Editor of Xcode.

display playground

Coding along with the tutorials

It is recommended that you learn a new coding language by typing the code yourself. As you follow with the video tutorials You will need to create a naming convention for your playgrounds and projects for this course. Because we are using different video tutorials some videos will suggest names for your playgrounds and project, but you should follow your own standard to stay organized.

NOTE

Choosing the iOS platform will import UIKit instead of Cocoa library. Either will be fine for learning Swift, but you should get in the habit of always choosing iOS right away.

The following videos offer a great introduction to the Swift programing language:

Swift Fundamentals - Reasons to Learn Swift Pluralsight

Swift Fundamentals - The Basic Structure of Swift Pluralsight

Swift Fundamentals - Writing and Running Swift in a Playground Pluralsight

Back to Week 2

Last Updated: 9/25/2020, 5:14:52 AM