Chapter 1: Swift Basic
Swift is new programming language for developing iOS and Mac OS applications. Apple at WWDC 2014 introduced Swift. Swift is not based on C and is different from the Objective C language. It takes the scripting approach making it easier for developer to understand. Apple main aim is to make Application developer life easier so that more and more solutions are uploaded on the App’s Store. In order to achieve this goal Swift is introduced.
For any language most important to understand is how variables, constants and functions are declared and are used. We will go into these one by one before we start writing the code in the Xcode.
1. SWIFT Variable
We declare variables in Swift by using “var” keyword. Throughout this book we will be using various real world examples to make things easier to understand. We will start with simple example of making ID making App. This App will help user to design the ID card.
For making the ID card for the student we need student unique code (roll number), first name, last name, course name, age and nationality.
We will declare all these parameters as variables in the program as follows
Suppose we need to initialize the variables than we will use following statement.
var rollNumber = 1
var firstName =“Priyank”
var courseName=“Programming Language”