I am downloading a large file structure from Firebase. However when printing the keys and values one of the subfolders is showing as <__NSArrayM> I tried to cast it to [String:Any] but it is crashing. Here is my code:
DATABASE.mainOrder.child("incomplete").observe(DataEventType.value, with: { (snapshot) in
let array = snapshot.value as! [String:[String:Any]]
for (_, value) in array {
for number in value {
if "\(number.key)" == "itemsInOrder" {
let items = number.value as! [String:Any]
//let items = Array(arrayLiteral: number.value)
print("itemsInOrder: \(items)")
} else {
print("\(number.key): \(number.value)")
}
}
}
})
However it is crashing and giving me this error:
Could not cast value of type '__NSArrayM' (0x2037d2608) to 'NSDictionary' (0x2037d21d0).
This is the code that I am trying to get:
itemsInOrder: [<__NSArrayM 0x281c060a0>({
amount = "2";
length = "5";
height = "7";
width = "10";
})]
Below is the Firebase json export
{
"TH000" : {
"docUUIDStatus" : "Sent",
"expectedShip" : "May 12, 2021",
"itemsInOrder" : [ {
"amountOrdered" : "2000 sq ft",
"bevel" : "None",
"floorLength" : "2-8",
"floorWidth" : "4",
"specialOrder" : "None",
"specialOrderLength" : "",
"status" : "completed"
} ],
"orderDate" : "May 11, 2021",
"orderNumber" : "TH000",
"orderNumberLowercased" : "th000",
"orderTime" : "2:30:30 PM",
"orderType" : "Order",
"purchaseOrderNumber" : "TH10051",
"purchaseOrderNumberLowercased" : "th10051",
"status" : "completed"
}
}