April 2015
Intermediate to advanced
556 pages
17h 47m
English
KVC will call setters and getters for properties, if they are present. To see this in action, add accessors for temperature:
dynamic var temperature = 68private var privateTemperature = 68 dynamic var temperature: Int { set { println("set temperature to \(newValue)") privateTemperature = newValue } get { println("get temperature") return privateTemperature } }
Run the application and move the slider to change the temperature. Notice how the setter is called, followed by the getter, the latter of which corresponds to bindings updating the label in response to the KVO notification. If you use the buttons to change the temperature you will see the setter (property access) and two getter calls (updating ...
Read now
Unlock full access