我的 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/