I'm trying to access an array using random indexes by using arc4random
to generate the random index. I'm sorry if my "technical usage of terms" are incorrect as I am fairly new to the development scene.
var backLeft = ["Clear","Drop","Smash"];
var i = (arc4random()%(3))
var shot = backLeft[i]
This gives me an error on the third line,
Could not find an overload for 'subscript' that accepts the supplied arguments.
But, if I use,
var i = 2
var shot = backLeft[i]
Then it doesn't give me any issues. Coming from a php background, I can't seem to have any clue what's going wrong here.
Thank You! :) PS: I'm trying this on XCODE 6 inside the Swift Playground