class ViewController: UIViewController {
let fortuneArray = [\"You will find true love in the summer.\", \"Outlook not good\", \"You may find great success in b
If the code you pasted is not defined in a method like viewDidLoad
, you cannot use a variable thats defined at the class level for another variable thats defined at the class level as well. These variables are determined at run time and the order they are determined is not known so fortuneArray may not exist before randomIndex is made (might not really work like this behind the scenes but you can think of it this way at least)
you should compute these variables inside viewDidLoad
or init
or some other function instead
Ah, I figured it out with Fonix's help. I declared the random number in an IBAction and that took care of it.