Chapter    3

Printing Variables and Constants

When you are prototyping your code with playgrounds, you automatically get output for any variable or constant that you are working with. But, if you are coding an application, you will need to use special functions to print out values to the console screen.

Since playgrounds have no console window, you will need to create a new Mac command-line tool to print values to a console screen.

Creating a Command-Line Tool

Open Xcode 6 and then choose Create a new Xcode project from the welcome screen.

On the screen that appears, choose OS X image Application Command Line Tool.

Click Next.

On the next screen, ...

Get Swift Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.