I watched a tutorial on swift basics and a passing comment was made that property observers can't be added to lazy properties, but no reason was given. Why is this the case?
The docs do confirm this:
You can add property observers to any stored properties you define, apart from lazy stored properties
source
but they do not provide a rationale.
I would guess that property observers must access the property they are observing to attach itself as an observer although it does not 'feel' like you are. Again, this is just a guess, but if I am correct, then obviously having a lazy property is irrelevant. Lazy properties are computed when first accessed and if using an observer accesses that property then it would be computed immediately, which completely defeats the purpose of it in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With