cs193p – Project #2 Assignment #2 Task #8

By 邰秉宥 from Changhua, Taiwan (Cryptic clothing label) [CC BY-SA 2.0 (http://creativecommons.org/licenses/by-sa/2.0)], via Wikimedia Commons

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

Modify the UILabel you added last week to show your CalculatorBrain’s description instead. It should put an = on the end of it (and be positioned strategically so that the display looks like it’s the result of that =). This = was Extra Credit last week, but it is required this week.

When setting the display value use the calculator-brain description for the history text (adding an equal sign).

[swift]
var displayValue: Double? {

set {

history.text = brain.description + " ="
}
}
[/swift]

And when starting a new number use it without the equal sign:

[swift]
@IBAction func appendDigit(sender: UIButton) {

history.text = brain.description != "?" ? brain.description : ""
}
}

[/swift]

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

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

Leave a Reply

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