diff --git a/AltStore/My Apps/MyAppsViewController.swift b/AltStore/My Apps/MyAppsViewController.swift index 5fe2cbd7..886d3dc4 100644 --- a/AltStore/My Apps/MyAppsViewController.swift +++ b/AltStore/My Apps/MyAppsViewController.swift @@ -38,6 +38,7 @@ private extension MyAppsViewController fetchRequest.returnsObjectsAsFaults = false let dataSource = RSTFetchedResultsTableViewDataSource(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext) + dataSource.proxy = self dataSource.cellConfigurationHandler = { (cell, installedApp, indexPath) in guard let app = installedApp.app else { return } @@ -56,3 +57,27 @@ private extension MyAppsViewController return dataSource } } + +extension MyAppsViewController +{ + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) + { + guard editingStyle == .delete else { return } + + let installedApp = self.dataSource.item(at: indexPath) + + DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in + let installedApp = context.object(with: installedApp.objectID) as! InstalledApp + context.delete(installedApp) + + do + { + try context.save() + } + catch + { + print("Failed to delete installed app.", error) + } + } + } +}