Hi,
First off; I know this is probably elementary stuff, and I´m taking courses to learn Swift, but I have a project on the side that I´m having a issue with:
I want to read data from Firebase Database, and post it back in a different node in the same Database. I have managed to get the data from the Database, but the constant isn´t reachable outside the scope.
This is the code I´m using:
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference()
let user = Auth.auth().currentUser!.uid
//Read data from Firebase
ref?.child("users").child(user).observeSingleEvent(of: .value, with: { (snapshot) in
guard let userDict = snapshot.value as? [String: Any],
let address = userDict["Address"] as? String,
let name = userDict["Name"] as? String else {
return
}
print(address + name)
})
}How do I need to go about to get the address and name constant?
Help with this is greatly appreciated