Skip to main content


Showing posts from November, 2019

Execute a method when a variable value changes in Swift

This post is about how to execute a function when a variable value changes. Instead of key-value observation, simply use a property observer for the variable.  For e.g: Whenever the value of variable named  allSlot  changes, the two lines will execute which are written in the  didSet  method. private var allSlot : [S tring ] = [] {         didSet {             slotTableView?.reloadData()             enableRightBarButton()         }      } Property observers: