O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

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

Type Properties

Up to now, you have been working with instance properties. Whenever you create a new instance of a type, that instance gets its own properties that are distinct from other instances of that type. Instance properties are useful for storing and computing values on an instance of a type, but what about values that belong to the type itself?

You can also define type properties. These are properties that are universal to the type – the values in these properties will be shared across all of the type’s instances. These properties store information that will be the same across all instances. For example, all instances of a Square type will have exactly four sides, so the number of sides for Square might be stored in a type ...

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