Hey everyone so I am following along the tutorial for project 2. I have redone it 3 times and it still does not work. When I run my app it only displays the US image 3 times despite at this point copying and pasting his code. I hav done exactly what he says for IB builder. Also I am not even able to click the button, I know if I click the button nothing will happen because I did not add code for it, however, the button should still "click" and do nothing. It is not even clicking.
import UIKit
class ViewController: UIViewController {
@IBOutlet var button1: UIButton!
@IBOutlet var button2: UIButton!
@IBOutlet var button3: UIButton!
var countries = [String]()
var score = 0
override func viewDidLoad() {
super.viewDidLoad()
countries += ["estonia", "france", "germany", "ireland", "italy", "monaco", "nigeria", "poland", "russia", "spain", "uk", "us"]
askQuestion()
}
func askQuestion() {
button1.setImage(UIImage(named: countries[0]), for: .normal)
button2.setImage(UIImage(named: countries[1]), for: .normal)
button3.setImage(UIImage(named: countries[2]), for: .normal)
}
}
So I solved my issue by the countries array string, I had to match the file names in the asset pictures with the names of the flag names in countries. I am confused why his code worked for him when he kept all the countires names as lower case?