I need the code in didSet
to be executed without changing the property's value.
Coming from Objective-C recently, there doesn't seem to be a setMyProperty()
.
So I tried:
self.myProperty = self.myProperty
which result in error Assigning a property to itself
.
Because myProperty
happens to be CGFloat
, I could do:
self.myProperty += 0.0
which does trigger didSet
and does not affect the value, but it doesn't show what I mean to do here.
Is there a way to call didSet
in a more clear/direct way?
Try this:
self.myProperty = { self.myProperty }()
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