Swift Programming Tutorial: Property Observers using didSet and willSet

How to run a code before or after a value changes

Photo by: Daniel Lerman on unsplash.com

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:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store