How do I add multiple Strings to one index in an Array? I had:
var cardNamesArray:[String] = ["card5", "card6", "card7", "card8", "card9", "card10", "card11", "card12"]
With, card5 at index 0, card6 at index 1, card7 at index 2, and so on. I want to assign card5, card6, card7, and card 8 to index 0, and card 9, card 10, card11, card12 to index 1. Can someone please tell me how to done this?
Is there any way I can do this without making an Array of Arrays and just assigning the cards to the index value?
var cardNamesArray:[[String]] = [["card5", "card6", "card7", "card8"], ["card9", "card10", "card11", "card12"]]
After making an Array of Arrays, I have only 2 indicies as I need, however I can't seem to call the String later on in Xcode. I have a UIButton randomizing a number and I want to connect the number to an image represented by one of the cards, but I want four of them to be of the same value.
var firstRandomNumber: Int = Int(arc4random_uniform(2))
I run into an error on this line saying
"cannot convert value type '[string]' to specified type 'String'.
var firstCardString: String = self.cardNamesArray[firstRandomNumber]
However when I put a [ ] around String in the first line above, it runs and I incur and error on the next line saying
self.firstCardImageView.image = UIImage(named: firstCardString)
"cannot convert value type '[string]' to expected argument type 'string'."
I would really appreciate any help! Thanks.