1. Swift: Introduction

Swift is a new programming language from Apple Corporation for iPhone and iOS development. This is an Object Oriented Programming language loaded with lots of new features. Apple is focusing more on Swift instead of Objective-C, which shows that Swift will replace Objective-C very soon.

To start working with Swift you need three things, an Apple machine, latest X-code software from apple store and passion. You are an experienced developer or newbie you must have passion to learn this language.

Swift PlayGround

Playground is a new interactive environment of Xcode which makes the Swift learning very easy. You can write your swift code and get your result at the same time. Before moving to the real application development, playground is a best place to play with new features.

Play ground contains 3 main interfaces:

1. Playground Editor: Where you write your code.

2. Result Panel: Where you will see the immediate output

3. Assistant Editor: Where you can see the detailed output of your code.
View -> Assistant Editor -> Show Assistant Editor

Screen Shot 2015-07-08 at 18.19.18

 

First PlayGround Application

Create your first swift application with File -> New -> Playground. Assign good name to your first application, select iOS for platform and select place where you want to save your file.

Screen Shot 2015-07-08 at 18.28.32

Once the file is created, you will see these two lines in HelloWorld file:

//: Playground - noun: a place where people can play
import UIKit

simply remove these lines and copy following code in your HelloWorld.playground file and see the magic.

var str = "Hello, playground"

var a = 10

for var i = 0; i < 10; i++ {

    println(i)

}

var isEmpty = true