繁体   English   中英

Swift 如何删除作为字典的子值

[英]Swift how to delete childs value which is an Dictionary

我尝试删除要删除的文档中的 child 值。 该值是一个字典,我需要删除整个字典,但 XCode 说:

无法将“字典”类型的值转换为预期的参数类型“[Any]”

这是我的代码:

var lists = [Dictionary<String, String>
             let washingtonRef = db.collection("Users").document(userid!)
             washingtonRef.updateData([
             "shoppingLists":
             FieldValue.arrayRemove(self.lists[sender.tag] as!
                 Dictionary<String,
                 String>)])

我使用以下代码解决了它:

 let washingtonRef = db.collection("Users").document(userid!)

        // Atomically add a new region to the "regions" array field.
        washingtonRef.updateData([
            "shoppingLists": FieldValue.arrayRemove([self.filteredData[sender.tag] as! Any])

            ])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM