我有一个名称表,我正在为它们创建一个滑动和删除函数,该函数将它们从一个名变量(数组)中删除.
我 Select 了与xcode中的教程最相似的函数并填写了它们,但当我点击删除按钮时,我的应用程序随机崩溃.以下是我的删除按钮代码:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let deleteAction = UITableViewRowAction(style: .destructive, title: "Delete") { (rowAction: UITableViewRowAction, indexPath: IndexPath) -> Void in
print("Deleted")
self.catNames.remove(at: indexPath.row)
self.tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
self.tableView.reloadData()
}
}
当我在学习swift 2和swift 3的新教程时,我会继续学习.