我正在爲實踐項目創建在線訂購服務。我最近讀到的兩件事是編輯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