Adds ability to delete controller skins

This commit is contained in:
Riley Testut 2019-10-10 12:13:48 -07:00
parent d7ed26c372
commit 4aa7a100e3

View File

@ -123,6 +123,31 @@ extension ControllerSkinsViewController
let controllerSkin = self.dataSource.item(at: IndexPath(row: 0, section: section))
return controllerSkin.name
}
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
{
let controllerSkin = self.dataSource.item(at: indexPath)
return !controllerSkin.isStandard
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath)
{
let controllerSkin = self.dataSource.item(at: indexPath)
DatabaseManager.shared.performBackgroundTask { (context) in
let controllerSkin = context.object(with: controllerSkin.objectID) as! ControllerSkin
context.delete(controllerSkin)
do
{
try context.save()
}
catch
{
print("Error deleting controller skin:", error)
}
}
}
}
extension ControllerSkinsViewController