Hello World!

Today we’re going to start learning Swift.  I assume you have some basic knowledge as a programmer and understand basic programming techniques such as variables, loops, conditionals, etc.  If not, do a little research online and come back when you’re ready.  To begin, let’s start with the much cherished “Hello World” program.  Power up xcode (you’ll need Xcode 6 to write swift code – download the latest version off the developer website).  Once you’ve that all ready, choose Playground and let’s be on our way. Screen Shot 2014-06-05 at 4.40.38 PM Once open, you’ll be presented with a nice little window to write yourswift code  Let’s get going. Swift is similar to JavaScript in its syntax.  To write a Hello World program, first delete the code xcode automatically gives you, but keep import cocoa.  Now let’s print some code.  You use the printIn command to print text to the screen.  Let’s print Hello World.

printIn("Hello, World!")

Note that you don’t need to use semicolons to end each line in Swift. This drastically differs from Objective-C (for the better).

Well, that’s that. You just wrote your first Swift program. Congrats.


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 )

Connecting to %s