Nested if statement in swift function

The following function counts down a red to green light, then counts the reaction time for the user to hit a button after the green light is displayed.

    func updateCounter() {

timerInt -= 1
if timerInt == 2{
    light.image = UIImage(named: "r.png")
} else if timerInt == 1 {
    light.image = UIImage(named: "yellow.png")


} else if timerInt == 0 {

    light.image = UIImage(named: arc4random_uniform(2) == 0 ? "no.png" : "g.png")


    timer.invalidate()
    startStop.isEnabled = true
    scoreTimer = Timer.scheduledTimer(timeInterval: 0.0001, target: self, selector: #selector(ViewController.updateScoreTime), userInfo: nil, repeats: true)

}
}

how can i write the code so that when it states “else if timerInt == 0”. The code will change timeIntervals depending on whatever arc4random images is chosen. So that when else if timerInt == 0 and no.png the time interval is 0.01 and when it states else if timerInt == 0 and g.png the time interval is 0.0001. Thanks

I would store the boolean of whether to show no.png or g.png, and continue to use ternary operators with that boolean for the values that need to change.

var shouldGo = arc4random_uniform(2) == 0 light.image = UIImage(named: shouldGo ? "g.png" : "no.png") scoreTimer = Timer.scheduledTimer(timeInterval: shouldGo ? 0.0001 : 0.01)
func updateCounter() {

	var imageName = "no.png"
	var interval = 0.01
	let goCondtion = arc4random_uniform(2) == 0

	timerInt -= 1
	switch (timerInt) {

	case 2:
		imageName = "r.png"

	case 1:
		imageName = "yellow.png"
		
	case 0: 
		if goCondtion {
			imageName = "g.png"
			interval = 0.0001
		}
		
		timer.invalidate()
		startStop.isEnabled = true
		scoreTimer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(ViewController.updateScoreTime), userInfo: nil, repeats: true)

	default:
		// do nothing
		break
	}			
	light.image = UIImage(named: imageName)
}