底线是我有 xcode 在这一行 tableView.deleteRows(at: [indexPath.row], with: .automatic) 发誓,但否则我不太明白如何按索引删除一行。它像这样发誓“无法将'Int'类型的值转换为预期的元素类型'Array.ArrayLiteralElement'(又名'IndexPath')”
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let place = places[indexPath.row]
let deliteAction = UIContextualAction(style: .normal, title: "Удалить") { (_ , _, completionHandler) in
StoregeMagager.deliteObject(place)
tableView.deleteRows(at: [indexPath.row], with: .automatic)
completionHandler(true)
}
let swipe = UISwipeActionsConfiguration(actions: [deliteAction])
return swipe
}
该方法
deleteRows
接受一个数组[IndexPath]
,所以试试