call coreDataManager.saveChanges after deleting an treatment

This commit is contained in:
Johan Degraeve 2022-01-03 10:52:55 +01:00
parent b1b4d4942b
commit 6a4ec16445
1 changed files with 4 additions and 0 deletions

View File

@ -155,6 +155,7 @@ extension TreatmentsViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if (editingStyle == .delete) {
guard let treatmentCollection = treatmentCollection, let treatmentEntryAccessor = treatmentEntryAccessor, let coreDataManager = coreDataManager else {
return
}
@ -165,8 +166,11 @@ extension TreatmentsViewController: UITableViewDelegate, UITableViewDataSource {
// Deletes the treatment from CoreData.
treatmentEntryAccessor.delete(treatmentEntry: treatment, on: coreDataManager.mainManagedObjectContext)
coreDataManager.saveChanges()
// Reloads data and table.
self.reload()
}
}