title: Need to correct this calculator program
body: <p>Unable to get the second value (var b) for calculation.</p>
  <p>In this calculator program I got the first value (var a) from display.text and cleared the display.text.Then getting the second value (var b) for adding/Subtrating, the second value still assigned to var a and getting error</p>
  <blockquote>
  <p>unexpectedly found nil for value b</p>
  </blockquote>
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var display: UITextField!
      @IBOutlet weak var nine: UIButton!
      @IBOutlet weak var eight: UIButton!
      @IBOutlet weak var seven: UIButton!
      @IBOutlet weak var six: UIButton!
      @IBOutlet weak var five: UIButton!
      @IBOutlet weak var four: UIButton!
  
      @IBOutlet weak var clear: UIButton!
      @IBOutlet weak var result: UIButton!
      @IBOutlet weak var add: UIButton!
      @IBOutlet weak var subtract: UIButton!
      @IBOutlet weak var multiply: UIButton!
      @IBOutlet weak var three: UIButton!
      @IBOutlet weak var two: UIButton!
      @IBOutlet weak var one: UIButton!
      var res : Int = 0
      var a : Int = 0
      var b : Int = 0
      var actionBtn : Int = 0
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view.
      }
  
      @IBAction func numbers(_ sender: Any) {
  
          display.text = display.text! + String((sender as AnyObject).tag)
          print(&quot;displtxt = &quot;, display.text)
      }
         
      @IBAction func functionality(_ sender: Any) {
          
          actionBtn = (sender as AnyObject).tag
          a = Int(display.text!)!
          print(&quot;a = &quot;, a)
          display.text = &quot;&quot;
      }
      
      @IBAction func clearDisplay(_ sender: Any) {
          display.text = &quot;&quot;
      }
      
      @IBAction func results(_ sender: Any) {
          b = Int(display.text!)!
          switch  actionBtn {
                  case 10:
                      print(&quot;b = &quot;, b)
                      res = a*b
                      print(&quot;res = &quot;, res)
          
                  case 11:
                      res = a-b
          
                  case 12:
                      res = a+b
          
                  default:
                      display.text = &quot;&quot;
          }
      }
  }
  
  </code></pre>