I am trying to make an app that takes the textField input, checks to see if it is within a range, then display the answer in a Label
Im having trouble defining my variable as an Integer. The code below gives me a
Value of optional type 'UITextField?' must be unwrapped to a value of type 'UITextField'
error.
@IBOutlet weak var depthTextField: UITextField!
@IBOutlet weak var pressureGroupLabel: UILabel!
@IBAction func enterButtonPressed(_ sender: Any) {
var Depth = Int(depthTextField)
if Depth < 40 {
pressureGroupLabel.text = "less than 40"
} else {
pressureGroupLabel.text = "more than 40"
}
Am I doing something wrong in regards to defining my variable as an Integer or is there a different problem I dont know about?
Aucun commentaire:
Enregistrer un commentaire