So I have 3 images
@IBOutlet weak var imageOne: UIImageView!
@IBOutlet weak var imageThree: UIImageView!
@IBOutlet weak var imageTwo: UIImageView!
I generate a random image from an array of images, the random image generated is the "correct" image
Here is how I was currently doing it
let randomIndex = Int(arc4random_uniform(UInt32(famousPeople.count)))
let correct = famousPeople[randomIndex]
self.imageOne.image = UIImage(named: correct)
Obviously the issue with this is the imageOne is always the correct image, I want the correct image to be random either one two or three.
I thought I could do the following
let randomImageIndex = Int(arc4random_uniform(UInt32(famousPeople.count)))
var imageArray: [String] = ["imageOne", "imageTwo", "imageThree"]
let randomImage = imageArray[randomImageIndex]
then
self.randomImage.image = UIImage(named: correct)
However I get the error message view controller no type random image.
Is there a good way to choose a random UI imageview? and then I want to assign to it my randomly chosen "correct" image
Extra context
The user can then choose the "correct" image and gets a message