iOS Development – Swift Playground


iOS Development with Swift 2 – Playground


”;


In this chapter, we will introduce a new environment where we can write and execute a swift code. We will also cover the following aspects of the swift playground −

  • Variables
  • Dictionaries
  • Arrays
  • Loops
  • Classes & Objects

Note − We will look only through those basic concepts, which we will be using in this tutorial, if you want to learn swift deeply, you can check our Swift Tutorial.

Playground is a tool provided with Xcode for executing the swift code. We will start by creating a new playground.

Starting Swift Playground

To create a swift playground, click on Xcode icon, and choose the first option, get started with a swift playground.

Started With Payment

Give the name to your playground and select Platform as iOS. Let us name our playground as the Demo Playground. Click on Next.

Name Platform

These are the only steps you need to follow to make a Playground. The following screenshot shows the Playground.

Demo Playground

Sr.No Basic Concepts & Description
1 Variables

A variable is a memory / storage that our program can use to store and manipulate data. Each variable has a specific data type, which determines the size that a variable will occupy in memory.

2 Dictionaries

A dictionary is a collection that stores values in a key value pair, i.e. the data stored in a dictionary is stored in a method where each value is related to a key. Here, every key is unique and cannot appear twice in the same dictionary.

3 Arrays

Arrays are the data types that store the same type of data in an ordered list. The same value can appear at multiple indexes/Places in an array.

4 Loops (Control Flow)

Swift provides a variety of Control Flow Statements. Loops are generally used to iterate over a condition or statement multiple times, until a Condition / Programmer’s need from that loop is satisfied.

5 Classes and Objects

Classes are the general-purpose flexible constructs that are the building blocks of your program’s code.

Object is the term that is generally used to refer to instance of a class, so we can call it instance instead of objects.

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *