This is my code:
let slotImages = ["SlotImage1", "SlotImage2", "SlotImage3", "SlotImage4", "SlotImage5", "SlotImage6", "SlotImage7", "SlotImage8", "SlotImage9", "SlotImage10"]
class cardsMinigame{
let cardImage: UIImage
let cardValue: Int
init(cardImage: UIImage, cardValue: Int){
self.cardImage = cardImage
self.cardValue = cardValue
}
}
var fakeCards = [[cardsMinigame](), [cardsMinigame](), [cardsMinigame]()]
And when adding a value to fakeCards, when using this code, I get the error "fatal error: index out of array" (the error is on this line as well):
fakeCards[i].append(cardsMinigame(cardImage: UIImage(named:"\(slotImages[random])")!, cardValue: random))
(where i is 0/1/2, random is < 10)
How can this occur? I am appending something to an empty array, I have no idea why it is out of index...