Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. class ViewController: UIViewController {
  2.  
  3. @IBOutlet weak var edadGatoTextField: UITextField!
  4. @IBOutlet weak var mensajeLabel: UILabel!
  5. @IBOutlet weak var imagenGatoImageView: UIImageView!
  6.  
  7. override func viewDidLoad() {
  8. super.viewDidLoad()
  9. // Do any additional setup after loading the view, typically from a nib.
  10. }
  11.  
  12. override func didReceiveMemoryWarning() {
  13. super.didReceiveMemoryWarning()
  14. // Dispose of any resources that can be recreated.
  15. }
  16.  
  17. @IBAction func calcularEdadButtonPressed(sender: AnyObject) {
  18.  
  19. var age = edadGatoTextField.text.toInt()
  20.  
  21. // *** Bellow is the error! I'm trying to figure out if user
  22. // has not entered any number in order to display the message.
  23.  
  24. if age {
  25.  
  26. age = age * 7
  27.  
  28. mensajeLabel.text = "Your cat's age is (age) years!"
  29. mensajeLabel.textColor = UIColor.blueColor()
  30.  
  31. edadGatoTextField.resignFirstResponder()
  32.  
  33. imagenGatoImageView.image = UIImage(named: "cat2.jpg")
  34.  
  35. } else {
  36.  
  37. mensajeLabel.text = "Please enter a number!"
  38. mensajeLabel.textColor = UIColor.redColor()
  39.  
  40. }
  41.  
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement