Allow deletion of imported profiles

This commit is contained in:
Davide De Rosa 2018-10-27 12:28:40 +02:00
parent 5dcc9ff970
commit 4098a15172
1 changed files with 11 additions and 0 deletions

View File

@ -99,4 +99,15 @@ extension ImportedHostsViewController {
cell.leftText = url.normalizedFilename
return cell
}
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
let url = pendingConfigurationURLs[indexPath.row]
try? FileManager.default.removeItem(at: url)
pendingConfigurationURLs.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .top)
}
}