The structure should be fairly straightforward
arrays //collection
array_doc_0 //document
array_0 //field
0: 10
1: 10
2: 10
array_1
0: 10
1: 10
2: 10
Then a class to hold the array of arrays
class MyArrayClass {
var myArrayOfArrays = [ [Int] ]()
}
In the above, the myArrayOfArrays is a var that would contain multiple arrays of Int arrays, like shown in the question.
[[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]
and then the code to read that structure from Firestore and populate a MyArrayClass object.
var myNestedArray = MyArrayClass()
let arraysCollection = self.db.collection("arrays")
let thisArrayDoc = arraysCollection.document("array_doc_0")
thisArrayDoc.getDocument(completion: { documentSnapshot, error in
if let err = error {
print(err.localizedDescription)
return
}
guard let doc = documentSnapshot?.data() else { return }
for arrayField in doc {
let array = arrayField.value as! [Int]
myNestedArray.myArrayOfArrays.append(array)
}
for a in myNestedArray.myArrayOfArrays { //output the arrays
print(a)
}
})
The end result will be an object, that has a var that is an array of arrays. The last part of the closure iterates over the object we created to verify it's value is an array of arrays. The output is
[10, 10, 10]
[20, 20, 20]