Created
June 9, 2019 08:31
-
-
Save kutakmir/07bf523d753bd583c0c4fa25c9e3538b to your computer and use it in GitHub Desktop.
How to save some data to the Firebase Database with a callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Database.database().reference().child("myFantasticUniqueKey").setValue("some data") { (error: Error?, reference: DatabaseReference) in | |
if let error = error { | |
print("Error: \(error.localizedDescription)") | |
} else { | |
print("Success!") | |
} | |
} | |
// Unique auto ID | |
Database.database().reference().child("myFantasticCollection").childByAutoId().setValue("some data") { (error: Error?, reference: DatabaseReference) in | |
if let error = error { | |
print("Error: \(error.localizedDescription)") | |
} else { | |
print("Success!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment