I want to display an alert when the value of textfield is 0. However, putting a value of 0 in the textfield does not show the alert.
How can I solve the problem?
@IBOutlet var priceTextfield: UITextField!
if Int(priceTextfield.text!) == 0 {
let aert = UIAlertController(title: "OK", message: "Price must be greater than 0.", preferredStyle: .alert)
let ok = UIAlertAction(title: "OK", style: .default)
alert.addAction(OK)
self.present(alert, animated: false)
}