- Get link
- Other Apps
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: https://docs.swift.org/swift-book/LanguageGuide/Properties.html#//apple_ref/doc/uid/TP40014097-CH14-ID262