O'Reilly logo

Mastering Swift 4 - Fourth Edition by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comments

Writing comments in Swift code is a little different from writing comments in Objective-C code. We can still use the double slash // for single-line comments and the /* and */ for multiline comments; however, if we want to use the comments to also document our code, we need to use the triple slash ///.

Xcode will also auto-generate a comment template based on your signature of the method/function by highlighting it and pushing command + option + / together.

To document our code we generally use fields that Xcode recognizes. These fields are:

  • Parameter: When we start a line with - parameter {param name}: Xcode recognizes this as the description of a parameter
  • Return: When we start a line with - return: Xcode recognizes this as the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required