What I want to do is set the image of firstCard to be equal to the image file with the name corresponding to firstCardString.
For instance, in the case below, the code could be setting self.firstCard.image to show the image named "card1" if it randomly picks it (I've clipped the rest of the array for brevity, the full thing contains 52 objects).
var deckArray = [
"card1": ["Bear","Ball"],
"card2": ["Bear","Ball"],
"card3": ["Bear","Ball"],
"card4": ["Bear","Ball"],
"card5": ["Bear","Ball"],
"card6": ["Bear","Ball"],
"card7": ["Bear","Ball"],
]
let firstRandomNumber = Int(arc4random_uniform(52))+1
let firstCardString = deckArray["card\(firstRandomNumber)"]
self.firstCard.image = UIImage(named: firstCardString)
Instead, I'm getting the following error:
Cannot convert value of type '[String]?' to expected argument type 'String'
I'm not entirely sure what this error message means, what is [String]??