This is my code to populate my 'Consumables' array (called in my viewDidLoad):
//---------------------- POPULATE CONSUMABLE ARRAY --------------------------------//
private func populateConsumableArray(){
//let the object populate itself.
self.ref?.child("Consumables").observe(.childAdded, with: { snapshot in
let dataChange = snapshot.value as? [String:AnyObject]
let aRequest = Consumable(aDict: dataChange!)
self.consumableArray.append(aRequest)
self.consumableTable.reloadData()
})
}
The Consumable object class is shown below
public class Consumable{
private var type:String
private var count:String
private var sku:String
init (aDict: [String: AnyObject]){
self.type = aDict["Type"] as! String
self.count = aDict["Count"] as! String
self.sku = aDict["SKU"] as! String
}
The data populates my table view just fine... Below is a picture of the code working...

As you can see by the two images above, the code loads the data just fine... The array is populated just fine as well, not shown because it's not directly related to the problem.
Below is a picture of the database structure:

Now when a new consumable is added via my add function the child added only grabs the first attribute added to the consumable item. (also not included, because I'm sure that is working fine, since it populates the firebase database online, which I will show)
The first attribute being 'Type', I switched the order of how things are added to firebase, added 'Count' first and count ended up being the only attribute grabbed. See the image below for what I mean...
Now you can see that 'Type' is the only attribute being grabbed and stored in the dataChange dictionary, rather than 'Type', 'Count' and 'Sku'.

This is what my firebase database looks like at the above breakpoint so I know that consumables are being added just fine to firebase, it's just a problem with grabbing them when a new child is added to the 'Consumable' parent:

And then, of course, the failure occurs in my Consumable object init function, since 'Count' and 'Sku' are not in the passed dictionary. See below for the fault:

If I close and reload the application, the table view loads with all the data, even the data I previously added that crashed the app. So my question, why does my populateConsumableArray function not grab all the children of the "Consumables" parent?
For the heck of it, I'll add my addConsumableToFirebase() function below, just in case that is the problem for some reason...


