I am new to Firebase and basically I want to access the elements in the documents that are the id fields in each of the documents and I want to loop through them, is there any way I can retrieve and put that data in some kind of array and later loop through the array in swift? I am new here in StackOverflow please don't mind if I didn't ask the question properly. The link to the image how my database looks like is below please go through it.
For This you have to setup Firebase Client SDK https://github.com/firebase/firebase-ios-sdk and after successfully setup
let db = Firestore.firestore()
db.collection("UniqueId's").getDocuments { (snapshot, error) in
if error != nil {
print(error)
} else {
for document in (snapshot?.documents)! {
if let id = document.data()["id"] as? String {
//Here you'll get your data
}
}
By the way I think your collection name may be a problem So if it is than change it's name to UniqueIds instead of UniqueIds
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.