I just started the Stanford iOS5 class and have completed the RPN calculator, but want to make the "Clear" button work a little differently. This is how I have it now, with no changes to the CalculatorModel "brain":
- (IBAction)clearPressed
{
self.display.text = @""; // Clear the display
self.historyWindow.text = @""; // Clear the history window
self.model = nil; // Reset the stack
self.userIsInMiddleOfEnteringNumber = NO; // Reset user typing boolean
}
I may be wrong, but "self.model = nil;" seems like it doesn't really remove the objects from the stack, it kind of just imitates that. So I added a function to the CalculatorModel "brain":
-(void) clearOperandStack
{
[self.operandStack removeAllObjects];
}
and want to call it in my "clearPressed" function in the CalculatorViewController but I am having issues possibly because I do not fully understand objective c yet. This is what I thought I had to do, but it does not seem to want to work.
- (IBAction)clearPressed
{
self.display.text = @""; // Clear the display
self.historyWindow.text = @""; // Clear the history window
// self.model = nil; // Reset the stack
[self.model clearOperandStack];
self.userIsInMiddleOfEnteringNumber = NO; // Reset user typing boolean
}
Can someone please explain to me the proper way to call that method / what I am doing wrong?
My solution of assignment 1: https://github.com/rl1987/CS193p-Homework-1