cs193p – Assignment #1 Task #8


Add a C button that clears everything (your display, the new UILabel you added above, any pending binary operations, etc.). Ideally, this should leave your Calculator in the same state it was in when you launched it.

Add the new button (or two) in story board:

Link it (them) to a new action. Reset the brain by initializing it again, as well as the display and the description. Don’t forget the view controller know, that now the user is not in the middle of typing any more:

    @IBAction func reset(_ sender: UIButton) {
        brain = CalculatorBrain()
        displayValue = 0
        descriptionDisplay.text = " "
        userIsInTheMiddleOfTyping = false

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


Flattr this!

Leave a Reply

Your email address will not be published. Required fields are marked *