Swift tutorial for beginners Part 2

Developing iOS Apps Using Swift

Fabio Rocha
Swift tutorial for beginners

--

Part 1: https://medium.com/swift-tutorial-for-begginers/swift-tutorial-for-begginers-part-1-da3392051de

Hi guys, on the first part of this tutorial we had a chance to do a small overview on iOS8 Swift, if you’ve missed it, access it here.

On this part we will create a small “Hello World” app.

Lets start, first we need to create a new Swift file:

Creating new Swift file

On the new file, add the base view overrides, this is very similar to Objective-c way, but with a different syntax. Now we define specifically “override func”:

RootViewController.swift

Have you noticed the new way of importing frameworks?

Swift import

Now we don’t need to import every class file manually, bye bye imports! We will take a look at this later on, for now we wont need to import any class.

Go to AppDelegate.swift and edit it like this:

We’ve defined our custom object as main controller, now we want to present something on our shinny new app. We will now add a Storyboard and set is as entry point for the app.

Creating new file
Setting target (you can either select iPhone or iPad)
We should now have something like this on the file navigator

Now we need to add a ViewController to the StoryBoard and set its class as RootViewController.

Lets add some Hello Word label and we’re ready to build!

On the next part we will create a navigation and add some logic to the RootViewController.

You can access the source files for this tutorial here.

Drop me a tweet @fabiojgrocha

Cya!

--

--