Hello World app in Swift

Hi Guys! So today we are going to make a Hello World app using Xcode and Swift. Lets get started!

So, the first thing you are going to do is download Xcode from the Mac App Store by searching “Xcode”. Then once you have downloaded and installed Xcode you are ready to begin!

Now launch Xcode and this window will appear:

Then select create a new Xcode project and choose a single view application. Name the project whatever you want and click next and save.

Next we need to go set up the interface so we need to go to the file that says Main.storyboard. once you have clicked on that this it should look like this:

Now lets add a label and two buttons:  ( The label will have no text.)

Add the constraints by going down to the pin icon at the bottom and select add missing constraints.

Open up the assistant editor and make two outlets and two actions. One action will go to the Hello button and the other will connect to the Good Bye button.

Next go to the ViewController.swift file and type this code:

Then run the app in the iOS Simulator by clicking the play button in the top left corner. When you press Hello the text will change to “Hello World!” and when you press Good Bye the text changes to “Good Bye!”

Thank you guys for using this tutorial!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s