在Firebase中删除字典元素 [英] Removing a dictionary element in Firebase

查看:34
本文介绍了在Firebase中删除字典元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除Firebase中的字典元素

I am trying to remove a dictionary element in firebase

我要删除对象:-

D8QmnOSH6vRYiMujKNXngzhdn992:真" PendingFriendRequests/RhiZYyMF7STn1vyA27HjnJRsLYb2 到目前为止,我已经提出了:-

D8QmnOSH6vRYiMujKNXngzhdn992: "True" at PendingFriendRequests/RhiZYyMF7STn1vyA27HjnJRsLYb2 so far i have come up with this :-

FIRControllerClass.ref.child("PendingFriendRequests").child(FIRAuth.auth()!.currentUser!.uid).observeSingleEventOfType(.Value, withBlock: {(Snapshot) in

                        let dict = Snapshot.value! as! NSMutableDictionary

                        for each in dict {
                        print(each)

                            print(acceptedFriend)

                            if each.key as! String == acceptedFriend{
                                print(each.key)
                                dict.removeObjectForKey(each.key)
                                print(dict)
                                }
                            FIRControllerClass.ref.child("PendingFriendRequests").child(acceptedFriend).setValue(dict)
                            }
                        })

推荐答案

var ref:DatabaseReference!

var ref: DatabaseReference!

ref = Database.database().reference()

ref = Database.database().reference()

FIRControllerClass.ref.child("parentKey").child("childKey").setValue(nil)

FIRControllerClass.ref.child("parentKey").child("childKey").setValue(nil)

这篇关于在Firebase中删除字典元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆