Property Observers (WillSet & DidSet) - Swift 5

Опубликовано: 18 Апрель 2019
на канале: Mobile App Mike
2,675
42

In this video, we go over the 2 computed properties in Swift: WillSet and DidSet. Here's the notes from the video:
Property Observers:
respond to changes in property’s value

willSet - called BEFORE new value is stored
use “newValue” in references and calculations

didSet - called immediately AFTER new value is stored
use “oldValue” in references and calculations

Both: can add custom parameter using parentheses after call (ex. willSet(heyyyy))

Download the source code (with added notes) here - https://github.com/mgm720/PropertyObs...

Check out my podcast, Swift Life, on your favorite platform! https://anchor.fm/michael-miles04

Twitter:   / milesoftweets  

Instagram:   / michaelmilestv