lundi 9 août 2021

If / Else won't run

I am working with the IF/Else training in Udemy and cannot see where my error/issue is. When I run the code, nothing happens and it doesn't activate an error(in XCode)

When I apply it to the (online)playground, it's identifying almost everything as an error. I'm a beginner. I'm follwong the lessons but if she doesn't supply the solution, I can't see where I went wrong. Help.

import UIKit

class ViewController: UIViewController {

let softTime = 5
let mediumTime = 7
let hardTime = 12

@IBAction func hardnessSelected(_ sender: UIButton) {

    let hardness = sender.currentTitle
}
func hardness(temp: Int){
    let hardness = Int.random(in: 0 ... 12)

    if hardness >= 10 {
        print("Hard Boiled")
    };if hardness <= 9{
        print("Medium Boiled")
    }else {
        print("Soft Boiled")
    }

} }

Aucun commentaire:

Enregistrer un commentaire