【发布时间】:2017-07-30 03:58:29
【问题描述】:
我正在为练习项目创建在线订购服务。我最近读到的两件事是编辑 tableview 功能。当我去滑动删除一个项目时,它不会从数据库中取出正确的项目。此外,如果数组中只有一个项目并且我尝试将其删除,则会使其崩溃。有人知道这是怎么回事吗?
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 {
}
}
}
【问题讨论】: