Commits

Jay Yu committed c8a2a3a

removed unnecessary if(), fixed bug with missing leading zero when pressing
backspace

Comments (0)

Files changed (2)

Calculator.xcodeproj/project.xcworkspace/xcuserdata/jay.xcuserdatad/UserInterfaceState.xcuserstate

Binary file modified.

Calculator/CalculatorViewController.m

 
 - (IBAction)backspacePressed
 {
-    if (self.userIsInTheMiddleOfEnteringANumber) {
-        NSUInteger length = [self.display.text length];
-        if (length > 0) {
-            self.display.text = [self.display.text substringToIndex:length - 1];
-        }
-        if (length == 0) {
-            self.userIsInTheMiddleOfEnteringANumber = NO;
-            self.display.text = @"0";
-        }
+    NSUInteger length = [self.display.text length];
+    if (length > 0) {
+        self.display.text = [self.display.text substringToIndex:length - 1];
+    } else {
+        self.userIsInTheMiddleOfEnteringANumber = NO;
+        self.display.text = @"0";
     }
 }