Hello,
The code below shows the number of items in a firebase data collection “messenger”. I have been trying to get this count to be returned as the count for rows in a tableview. I have’t had success yet it as it does’t show everything. it always show 3 of the five rows and I would like for them to be arranged according to date it was posted. I keep getting errors like “Thread 1: Fatal error: Index out of range” Please help!
// get the count of collections
func getCollections() {
let db = Firestore.firestore()
db.collection("messenger").getDocuments()
{
(querySnapshot, err) in
if let err = err
{
print("Error getting documents: \(err)");
}
else
{
var count = 0
for document in querySnapshot!.documents {
count += 1
print("\(document.documentID) => \(document.data())");
}
print("Count = \(count)");
}
}
}