// Escribir datos
ref.child("users").child("userId").setValue(["name": "John", "age": 30])
// Leer datos
ref.child("users").child("userId").observeSingleEvent(of: .value) { (snapshot) in
if let value = snapshot.value as? [String: Any] {
let name = value["name"] as? String ?? ""
let age = value["age"] as? Int ?? 0
print("Name: \(name), Age: \(age)")
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter