Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ViewController: UIViewController {
- @IBOutlet weak var edadGatoTextField: UITextField!
- @IBOutlet weak var mensajeLabel: UILabel!
- @IBOutlet weak var imagenGatoImageView: UIImageView!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view, typically from a nib.
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- @IBAction func calcularEdadButtonPressed(sender: AnyObject) {
- var age = edadGatoTextField.text.toInt()
- // *** Bellow is the error! I'm trying to figure out if user
- // has not entered any number in order to display the message.
- if age {
- age = age * 7
- mensajeLabel.text = "Your cat's age is (age) years!"
- mensajeLabel.textColor = UIColor.blueColor()
- edadGatoTextField.resignFirstResponder()
- imagenGatoImageView.image = UIImage(named: "cat2.jpg")
- } else {
- mensajeLabel.text = "Please enter a number!"
- mensajeLabel.textColor = UIColor.redColor()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement