ios - Calculator code in Swift doesn't work -


i learning swift, , watched lecture stanford university, in instructor teaching write code 1 calculator. before finish code changed idea , did same thing code. i'd know how previous code taught.

the piece of code not working between /* */ comments. there 4 operations, times operator working, others 3 not.

thanks in advance! , sorry english, learning it.

import uikit  class viewcontroller: uiviewcontroller {      @iboutlet weak var display: uilabel!      var usermiddletyping:bool = false      @ibaction func appenddidit(sender: uibutton) {         let digit = sender.currenttitle!         if usermiddletyping {             display.text = display.text! + digit         }         else {             display.text = digit             usermiddletyping = true          }      }      @ibaction func operate(sender: uibutton) {         let operation = sender.currenttitle!         if usermiddletyping {             enter()         }         switch operation {             case "×":                 if operandstack.count >= 2 {                 displayvalue = operandstack.removelast() * operandstack.removelast()                     enter()              }       /************ not working code starts here **************/             case "÷":                  if operandstack.count >= 2 {                     displayvalue = operandstack.removelast() / operandstack.removelast()                     enter()             }             case "+":                if operandstack.count >= 2 {                     displayvalue = operandstack.removelast() + operandstack.removelast()                     enter()             }             case "−":                 if operandstack.count >= 2 {                     displayvalue = operandstack.removelast() - operandstack.removelast()                     enter ()             }      /************ not working code ends here **************/              default: break           }      }      var operandstack = array<double>()      @ibaction func enter() {         usermiddletyping = false         operandstack.append(displayvalue)         print("operandstack \(operandstack)")     }       var displayvalue:double {     {         return nsnumberformatter().numberfromstring(display.text!)!.doublevalue     }     set{         display.text = "\(newvalue)"         usermiddletyping = false          }     } } 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -