【发布时间】:2020-05-05 19:46:19
【问题描述】:
您好,我正在尝试删除我使用 siwft 在 firebase 上创建的测试帖子,但我使用的代码删除了所有帖子,我只想删除 1 个被选中的帖子。在下图中,我想删除红色箭头具体指向的位置。
此代码显示了它如何存储到 Firebase。
guard let prof = uServe.currentUserProfile else {return}
let postRef = Database.database().reference().child("posts").childByAutoId()
let pObj = [
"author": [
"uid": prof.uid,
"name": prof.name,
"photo": prof.photo.absoluteString
],
"text": textView.text,
"timestamp": [".sv":"timestamp"]
] as [String:Any]
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
self.theposts.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .left)
Database.database().reference().child("posts").childByAutoId().removeValue()
}
}
【问题讨论】:
标签: swift xcode firebase uitableview firebase-realtime-database