I have the following code in my Swift 4 project.
class DishesTableViewController : UITableViewController {
private var token :NSKeyValueObservation?
@objc dynamic private(set) var dishes :[Dish] = []
override func viewDidLoad() {
super.viewDidLoad()
// configure the observation
token = self.observe(\.dishes) { object, change in
// change is always nil
print(object)
print(change)
}
updateTableView()
}
Whenever the dishes array is changed, the observation is triggered. But my question is how can I get the actual changes that happened, that is, how can I access the actual Dish object that triggered the change?