Please note, this blog entry is from a previous course. You might want to check out the current one.
When the user hits an operation button, put an = on the end of the text label that is showing what was sent to the brain (required task #4). Thus the user will be able to tell whether the number in the Calculator’s display is the result of a calculation or a number that the user has just entered.
Basically we add an equal sign in operationPressed:
1 | self .history.text = [ self .history.text stringByAppendingFormat: @" %@ =" , sender.currentTitle]; |
but have to remove it again fur further entries. We can do this using a helper function
1 2 3 4 5 6 7 | - ( void )removeEqualSignFromHistory; { NSRange range = [ self .history.text rangeOfString: @"=" ]; if (range.location == NSNotFound ) return ; NSString *history = [ self .history.text copy ]; self .history.text = [history substringToIndex:([history length] - 2)]; } |
which we call every time we need to (before changing the history):
1 | [ self removeEqualSignFromHistory]; |













