title: Declaring a variable as Integer in Swift
body: <p>So I'm trying to learn swift and on button action, I want to declare a variable as an integer that collects the value from a text field, calculates if it is not nil and prints the value. Why is it asking me to make the variable constant?</p>
  
  <p>This what I've tried </p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var enterAge: UITextField!
      @IBOutlet weak var catAge: UILabel!
  
      @IBAction func findAge(sender: AnyObject) {
  
          var newage = Int(enterAge.text!)
  
          if newage! == 0
          {
  
         var catyears = newage! * 7
          catAge.text = "Your cat is \(catyears) in age"
          }
  
          else
          {
  
              catAge.text = "Please enter a whole number"
          }
  
      }
          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.
      }
  
  
  }
  </code></pre>
  
  <p>Xcode version 7.1
  The error:
  <a href="https://i.stack.imgur.com/XWVep.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XWVep.png" alt="enter image description here"></a></p>
  
  <p>Thanks</p>