cs193p – Assignment #1 Task #8

Please note, this blog entry is from a previous course. You might want to check out the current one.

Add a C button that clears everything (your display, the new UILabel you added above, etc.). The Calculator should be in the same state as it is at application startup after you touch this new button.

Add a clear button (or two) in the interface builder:

Storyboard calculator adding clear buttons
Storyboard calculator adding clear buttons

Link the button(s) to a new action method which resets the calculator model and the two displays:

@IBAction func clearEverything(sender: UIButton) {
  brain = CalculatorBrain()
  display.text = "0"
  history.text = " "
}

The complete code for task #8 is available on GitHub.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

2 thoughts on “cs193p – Assignment #1 Task #8”

  1. Shouldn’t you set “userIsInTheMiddleOfFloatingPointNummer” to false, too? Otherwise the user can’t enter a floating point number directly after tapping the clear button because that var is still true.

Leave a Reply

Your email address will not be published.