Property observers

Property observers are used to respond to change in a property's value. Property observers are called every time a property's value is set, even if the new value is the same as the property's current value. We have the option to define either or both of the following observers on a property:

  • The willSet observer is called just before the value is stored
  • The didSet observer is called immediately after the new value is stored

The willSet and didSet observers are not called when a property is set in an initializer before delegation takes place.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset