So far we've seen how to store values in properties and calculate them dynamically with computed properties. But what if you want to react every time a property changes โ€” automatically, without having to remember to call a function yourself? That's exactly what property observers are for. ๐Ÿฅ

Swift gives us two flavors:

didSet โ€” runs after the property changes

willSet โ€” runs before the property changes

The Problem Without Property Observers