首页 > 解决方案 > 我的代码中出现“线程执行断点”问题,试图将文档添加到 firestore 子集合中

问题描述

我正在尝试通过函数将文档添加到在我的 firestore 数据库中找到的文档的子集合中。但不幸的是,它会导致线程执行错误,我显然无法说出问题所在。

我在其他此类函数中使用了相同的方法,使用文档唯一 ID 作为对特定文档的引用点。但我不知道为什么这种特殊情况会出错

代码错误:

 func addComment(from data:[String:Any], completion: @escaping (Bool) -> ()){
        db.collection("Events").document((event?.uid)!).collection("Comments").addDocument(data: data) { (error) in // This line causes Thread Breakpoint
            if error != nil {
                print(error?.localizedDescription)
                return
            }

        }
        completion(true)
    }

它应该添加一个带有自动生成的 id 集的文档,其中包含解析的数据 线程断点错误

标签: iosswiftfirebasegoogle-cloud-firestore

解决方案


推荐阅读