In TerningspilletSpillereViewController I have an array that looks like this:
var mineSpillere = ["1SP", "2SP", "3SP"]
and this under:
func assignArray() {
let obj = TerningspilletViewController()
obj.mineSpillere2 = self.mineSpillere
}
In my other UIViewController (TerningspilletViewController) I have this
var mineSpillere2 = [String]()
I want to generate a random (1SP, 2SP or 3SP) on button click like this from a function:
func generateNumber() {
let array = aBB
let randomIndex = Int(arc4random_uniform(UInt32(array.count)))
randomLabel.text = (array[randomIndex])
}
But this gives me the following error:
fatal error: Array index out of range.
I this line randomLabel.text = (array[randomIndex])
Why is that?