O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

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

Types in Swift

Swift types can be arranged into three basic groups: structures, classes, and enumerations. There are other types that fall outside of these three, such as closures, but these are the building blocks of Swift. All three can have

  • properties: values associated with a type

  • initializers: similar to a function, code that initializes an instance of a type

  • instance methods: functions specific to a type that can be called on an instance of that type

  • class or static methods: functions specific to a type that can be called on the type itself

Figure 2.1  Swift building blocks

Swift building blocks

Swift’s structures and ...

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