@IBAction func getGoo(_ sender: Any) { let results1 = ["Image1","Image2","Image3"] let random1 = arc4random_uniform(UInt32(results1.count)) let image1 = UIImage(named: results1[Int(random1)]) imageView.image = image1 } @IBAction func getChoki(_ sender: Any) { let results2 = ["Image1","Image2","Image3"] let random2 = arc4random_uniform(UInt32(results2.count)) let image2 = UIImage(named: results2[Int(random2)]) imageView.image = image2 } @IBAction func getPa(_ sender: Any) { let results3 = ["Image1","Image2","Image3"] let random3 = arc4random_uniform(UInt32(results3.count)) let image3 = UIImage(named: results3[Int(random3)]) imageView.image = image3 }
let result, let randomを3回書くと、うまく表示されません。varだったら行けるのかもしれませんが。