Book Image

iOS 9 Game Development Essentials

By : Chuck Gaffney
Book Image

iOS 9 Game Development Essentials

By: Chuck Gaffney

Overview of this book

Table of Contents (15 chapters)
iOS 9 Game Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Commenting in Swift


In our code snippets thus far, one might note notations with double forward slashes // or with forward slashes and asterisks /* */. These are how we can comment or make notations in our Swift code. Anyone who's coded in C++, Java, Objective-C, JavaScript, or other languages will see that Swift works practically the same.

Single-line comments are started with the double forward slashes, //, while multiline comments or a comment block begins with /* and ends with */.

Take the following example:

//This is a single line comment
/*
This is a comment block
that won't end until it reaches the closing asterisk/forward slash characters
 */

Commenting is used to help navigate your code, understand what it might do, and comment out lines of code we might not want to execute, but at the same time want to keep for later (that is, print() log calls or alternative starting property values).

Note

From Xcode 6 Beta 4 onward, we can also utilize the following comments:

// MARK:, // TODO:, and // FIXME. //MARK is equivalent to Objective-C's #pragma mark, which allows the programmer to label a section of your code that is accessible in Xcode's top breadcrumb dropdown list. // TODO: and // FIXME give us the ability to section off parts of code that we wish to maybe add features to in the future or debug. Even games with well-organized class structuring can be daunting to sift through. The addition of these additional mark-up tools makes planning and searching through our games' code that much easier to do.