ios - Firebase 实时数据库 iOS 删除键

标签 ios swift firebase firebase-realtime-database

我的 iOS 应用程序上有一个实时数据库。现在正试图从客户端添加功能来删除他们的 user_id 和历史记录。根据文档,将是 removeValue 函数。但是,当我运行时,我收到一个快速错误。这是我的代码:

 self.roofRef.child(user_name as! String).childByAutoId().setValue(dict)
 let conditionRef_ex = self.roofRef.child(user_name as! String)
 conditionRef_ex.observe(.value) { (snap: DataSnapshot) in
 let _tester = snap.value.debugDescription

 // here is line of code to remove user, which is causing the error    
 self.roofRef.removeValue(completionBlock: user_name as! (Error?, DatabaseReference) -> Void)

最佳答案

我明白了:您必须填写 removeValue 方法的完成 block ... 您还可以通过将 nil 指定为另一个写入操作(例如 setValue 或 updateChildValues)的值来删除。

关于ios - Firebase 实时数据库 iOS 删除键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51546205/

相关文章:

ios - 检查 tabBar 是否为 nil

Angular 7 在 09 :41 am 开始一个函数

javascript - 在 firebase 中计算点赞数

iphone - 非 ARC(自动引用计数)和 ARC 用户的开源

ios - 来自 PL SQL 的 Apple 推送通知

ios - 何时创建自定义数据源方法而不是设置变量

javascript - 使用 firebase 将文档、pdf 上传到谷歌云。得到错误

iphone - iTunes connect 默认添加光泽效果

Swift3:为什么这个简单的代码块需要很长时间才能编译

ios - 当 UITableView 放在 tableview 页脚上时,将单元格移动到最后一行