This is a good time to talk briefly about getters and setters in Swift. In Swift, you can have a property of a class that is a getter or a setter or both. To see how this works, you’ll create a class called Human, and then you’ll see what it means to get and set properties of that class:

class Human {    var eyeColor = "#00FF00"    var heightInInches = 68    var hairLengthInCM = 2.54    var name = "Skip"}

This class has four properties. You may or may not want all of these properties to be able to be rewritten. For example, once the eye color is set, you might only want that to be able to be read and not written to. There are also other details you can get from these properties being set. For example, ...

Get Learning Swift™ Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.