Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Swift

You're reading from   Learning Swift Build a solid foundation in Swift to develop smart and robust iOS and OS X applications

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher Packt
ISBN-13 9781784392505
Length 266 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Andrew J Wagner Andrew J Wagner
Author Profile Icon Andrew J Wagner
Andrew J Wagner
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Introducing Swift 2. Building Blocks – Variables, Collections, and Flow Control FREE CHAPTER 3. One Piece at a Time – Types, Scopes, and Projects 4. To Be or Not to Be – Optionals 5. A Modern Paradigm – Closures and Functional Programming 6. Make Swift Work for You – Protocols and Generics 7. Everything is Connected – Memory Management 8. Writing Code the Swift Way – Design Patterns and Techniques 9. Harnessing the Past – Understanding and Translating Objective-C 10. A Whole New World – Developing an App 11. What's Next? Resources, Advice, and Next Steps Index

Printing on the console

It can be very useful to write output to a log so that you can trace the behavior of some code. As a code base grows in complexity, it can be hard to reason about the order in which things happen and exactly what the data looks like as it flows through the code. Playgrounds can help a lot with this, but this is not always enough.

In Swift, this process is called printing to the console. To do this, you use something called println, which is short for print line. It is used by writing println followed by some text surrounded by parenthesis. For example, to print Hello World! to the console, the code would look like this:

println("Hello World!")

If you put that code into a playground, you will see "Hello World!" written in the results pane. However, this is not truly the console. To view the console, you can go to View | Assistant Editor | Assistant Editor. A new view will appear to the right of the results pane and it will have a section called Console...

You have been reading a chapter from
Learning Swift
Published in: Jun 2015
Publisher: Packt
ISBN-13: 9781784392505
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image