I'm new to firebase and swift in general, and I was really confused on how to access information from a firebase database. So basically, I put in this data into my database:
I did all the setup and everything in xcode. However, I've been clueless on how to access this data? I have a model like this:
I looked through the firebase documentation and it seems you can get a NSDictionary from the snapshot.value, so that's what I did here:
var ref:FIRDatabaseReference!
var handle:FIRDatabaseHandle!
override func viewDidLoad() {
super.viewDidLoad()
ref = FIRDatabase.database().reference()
ref?.child("series").observe(.value, with: { (snapshot) in
let dict1 = snapshot.value as? NSDictionary
let value1 = dict1?.allValues
for i in 0...(snapshot.childrenCount - 1)
{
//???
}
})
But as far as I know, NSDictionary isn't an array of objects, and you can't call an index and a property from the object at that index, like arrayofobjects[3].property, so I want to transfer it with for loops to an array of objects of type Model so that I can use the information in my app. Is that how you're supposed to do it? How do I transfer it to an array of objects when you can't take an index of NSDictionary?