I have two view controllers.
VC1 - Displays data in a tableView, selecting one of the cells goes to VC2. VC2 - Show text fields to edit the data.
Question - After updating the data and going back to VC1, it does not show the updated data in the table.
I did try adding tableView.reloadData() in ViewWIllAppear but the ViewWillAppear method is not called when I dismiss VC2.
//CODE BELOW VC2 -
@IBAction func saveTask(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(true)
view.endEditing(true)
if let task = task {
task.completed = toggleStatus.isOn
}
}
VC1 -
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
tableView.reloadData()
}
You have to update the item in the collection of your data that selected from table view
Example:
UPDATED