我正在为实践项目创建在线订购服务。我最近读到的两件事是编辑tableview函数。当我去滑动删除一个项目时,它不会从数据库中取出正确的项目。另外,如果数组中只有一个项目,我试图删除它,它会使它崩溃。任何人都知道这是怎么回事?从Firebase数据库中删除
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
orderNumber.remove(at: indexPath.row)
itemsArray.remove(at: indexPath.row)
priceArray.remove(at: indexPath.row)
quantityArray.remove(at: indexPath.row)
databaseRef.child("Users/\((authRef.currentUser?.uid)!)/Order/\(orderNumber.remove(at: indexPath.row))").removeValue { (error, ref) in
if error != nil {
print(error?.localizedDescription as Any)
} else {
}
}
}
它仍然崩溃。问题发生在数据库引用调用中。我在调试器中得到的唯一结果是“索引超出范围” – user3103854