Thursday, June 5, 2014

Apple Swift Programming Language - Hello World

Swift is a new programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility.

In my efforts to learn the new language, I’ve decided I will be posting regularly as I step through the learning process, sharing everything I find. This is the first post of many on the topic, and I hope you decide to follow along!

Let's start with basic Xcode template..

1.  Create an Empty Application:

2. Now create a new UIViewController which will act as a rootViewController

3. So for instance in Objective-C where you have this:
 RootViewController *vc = [[RootViewController alloc] init];  

You now have this:
 var vc = RootViewController()  

4. You may have to get rid off from designated initializer from RootViewController class or you have to create instance with:
 var vc = RootViewController(nibName: nil, bundle: nil)  

5. Now create instance of UINavigationController and attach your vc instance to the rootViewController.

6. Build and run!

Source Code

We will cover Swift basics in next Article


Submit Express Inc.Search Engine Optimization Services