Swift Programming Tutorial: Property Observers using didSet and willSet
How to run a code before or after a value changes

For the sake of convenience, property observers are built so that developers doesn’t need to write a code repeatedly each time a value of a property (or a variable) changes. There are basically 2 kinds of property observers: