class RoomFeed: UIViewController, UITableViewDelegate, UITableViewDataSource{
let posts = Post(id: self.documentId , author: owner!, text: text!, amount: self.amount)
//This is called in the view controller which is "host of table View"
//Document Id at this point is not nill confirmed.
}
class PostTableVIewCell: UITableViewCell {
//This is table view cell
var king: String!
var postID: String!
override func awakeFromNib() {
super.awakeFromNib()
Firestore.firestore().collection("GeneralData").document("\(self.postID)").getDocument { document, err in
if let document = document, document.exists {
let data = document.data()
self.king = data!["1"] as? String
let placeamount = data!["amount"] as? String
self.amountLabel.text = placeamount
}
print("KING: \(self.king!)")
self.kingLabel.text = self.king
}}
func set(post:Post) {
usernameLabel.text = post.author
PostTextLabel.text = post.text
self.amount = post.amount
postID = post.id
}
}
This is my code but I'm getting an error which states "'FIRESTORE INTERNAL ASSERTION FAILED: Invalid document reference. Document references must have an even number of segments" what am I doing wrong?
let placeamount = data!["amount"] as? Int
– Gius