Still pretty new to Swift I want to use an array of arrays of integers. I thus write the following in the function that makes use of it.
var allSetsOfCards: [[Int]]
I don't know before the app starts running what exactly will be in it or how big it will be except that each array in it will contain three integers so I can't specify exactly what it will look like when I introduce it. Later I want to add some information to it in the following way:
allSetsOfCards[setNumber][0] = i
allSetsOfCards[setNumber][1] = j
allSetsOfCards[setNumber][2] = k
where setNumber
, i
, j
, and k
are integer-variables. This gives me the error message:
Variable 'allSetsOfCards' passed by reference before being initialized.
What do I need to do? I searched this site and found one entry that seemed to cover the topic (Two-dimensional array in Swift) but I was unable to understand it. No amount of googling seems to work either. An answer to my specific problem would be great. A brief easy to understand explanation of how swift handles arrays would be terrific.