- October 14, 2014
- Posted by: Multidots
- Category: Enterprise Mobility,Resource & Tools

In iOS 8, many new features are provided by Apple. Swift programming language is one of them. Swift is used for Cocoa and Cocoa Touch. This new language is very interactive, safe and fast. Also, it is a very simple and easy to understand and maintain.
Swift is is used for iOS and OS X apps. You can easily understand the syntax and use it in project. You will need Xcode 6 to write code in Swift.
Features
- Very fast and powerful
- Any function code available in one pointer
- Safe and interactive
- With these features, it also supports some of objective-c features like methods, extensions, protocols
- Returns multiple values
- Generics
- Interactive playgrounds
- Automatic memory management
- Easy to understand and maintain
How to create Swift project?
Xcode 6 is must for this. If you don’t have the Xcode 6, you can download it from https://developer.apple.com/ link and install it.
Open the Xcode 6 and create new project with Empty Application like below.
In next screen, select “Swift” in Language option from the dropdown list like below.
When you click on Next button, you will see the next screen something like below with AppDelegate.swift file.
AppDelegate.swift
You can see that the structure of swift is same as objective-c in AppDelegate. Here, this is default code of your new Swift project or application.
Now, here you can add RootViewController in didFinishLaunchingWithOptions function of AppDelegate.swift class like below.
Now build app and you will see below output on simulator.
In above code, we declared rootViewController and set backgroundColor to purpleColor. Now, let’s add UILable just for an example that how to addSubview to UIView in Swift like below.
Here we have changed the backgroundColor of RootViewController with white Color and added UILable just as an example. See the output below.