'How do I read data from the Firebase Realtime DataBase
I need to read the data every time it gets updated in the real-time database. Getting many errors with different codes I've tried from various tutorials online. I simply want to store the value in an integer that I can use in the rest of my code.
import SwiftUI
import FirebaseDatabaseSwift
import FirebaseDatabase
import Firebase
struct DataTest: View {
let ref:DatabaseReference! = Database.database().reference()
let offsetRef:DatabaseReference! = Database.database().reference().child("offset")
var body: some View {
self.offsetRef.observe(.value, with: { DataSnapshot in
print(DataSnapshot.value)
})
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
