title: NSInteger 0+0=4300282608
body: <p>I am developing a simple calculator app to understand how OSX development works (this is not homework). When <code>addAction(_ sender: NSButton)</code> is fired it adds the <code>currentCount</code> and <code>amountToAdd</code> together then updates the <code>currentCount</code> and sets that to <code>currentCountLabel</code>.</p>
  
  <p>The Issue: When the app first starts <code>currentCount</code> and <code>amountToAdd</code> are set to 0 but when added together equals 4,300,282,608. If I hit the clear button before doing addition it equals 0 which is correct.</p>
  
  <p>The Question: How can I change the code do the correct calculation the first time. It appears to be a casting issue.</p>
  
  <pre><code>import Cocoa
  
  class ContainerViewController: NSViewController {
  
      var currentCount: Int = 0
      var amountToAdd: Int = 0
  
      @IBOutlet weak var currentCountLabel: NSTextField!
      @IBOutlet weak var amountToAddTextField: NSTextField!
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
          currentCountLabel.integerValue = 0
          amountToAddTextField.integerValue = 0
      }
  
      @IBAction func amountTextField(_ sender: NSTextField) {
          amountToAdd = amountToAddTextField.integerValue
      }
  
      @IBAction func addAction(_ sender: NSButton) {
          currentCount = currentCount + amountToAdd
          currentCountLabel.integerValue = currentCount
      }
  
      @IBAction func clearAction(_ sender: Any) {
          currentCount = 0
          amountToAdd = 0
          currentCountLabel.integerValue = 0
          amountToAddTextField.integerValue = 0
      }
  
      func getEntryLog() -&gt; String {
          return "\(currentCount) + \(amountToAdd) = \(currentCount + amountToAdd)"
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0QaYB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0QaYB.png" alt="enter image description here"></a></p>
  
  <p>Upon uploading the image current count ends up being a random number on each run...</p>