为什么会出现“不受支持的__SwiftValue类型”错误?

时间:2020-06-24 23:06:25

标签: ios swift google-cloud-firestore swift5

我正在尝试对用户帖子进行排序,以便仅将关注的用户帖子显示在UITableView上。我正尝试将Firestore查询返回的数据放入Array,我认为这是我要出问题的地方。下面,我详细介绍我的代码和数据库设置:

override func viewDidLoad() {
    super.viewDidLoad()
   // getFollowingPosts()
    configureTableView()
    
    db.collection("iAmFollowing").document(currentUserID!).getDocument { (document, error) in
        if error != nil {
            print("ERROR")
        } else {
            if let document = document, document.exists {
                let data = document.data()
                let followingUsers = Array(arrayLiteral: data?.values)
                self.db.collection("posts").whereField("uid", isEqualTo: followingUsers).getDocuments { (querySnapshot, error) in
                for documents in querySnapshot!.documents {
                let uid = documents.get("uid") as! String
                let title = documents.get("Title") as! String
                let ProfilePictureURL = documents.get("ProfilePictureURL") as! String
                let username = documents.get("username") as! String
                let content = documents.get("Content") as! String
                let postedTime = documents.get("Posted")
                self.titleArray.append(title)
                self.usernameArray.append(username)
                self.contentArray.append(content)
                print(self.titleArray)
            }
        }
    }
}
    }
}

我的数据库的结构:

我有一个“ iAmFollowing”集合,其中包含每个用户的文档(根据用户的UID命名)。每个文档中都有字段“((用户的用户名)”)和值:“(UID)”。

任何帮助将不胜感激-我已经在此上停留了很长时间了。

谢谢

0 个答案:

没有答案