I have run the console/debug several times now and have tried to modify this file, however it continues to find these 2 errors. Does anyone have any idea where I went wrong with this one?
I get this error code twice right after this curly.
/Users/Paul/Documents/LPD/Stanford Iphone Courses/CalculatorStanford/Classes/CalculatorStanfordViewController.h:21:0 /Users/Paul/Documents/LPD/Stanford Iphone Courses/CalculatorStanford/Classes/CalculatorStanfordViewController.h:21: error: expected ';' before '{' token
Below is the m. file.
Code:
#import <UIKit/UIKit.h>
#import "CalculatorBrain.h"
@interface CalculatorStanfordViewController : UIViewController
{
IBOutlet UILabel *display;
CalculatorBrain *brain;
BOOL userIsInTheMiddleOfTypingANumber;
}
-(IBAction)digitPressed:(UIButton *)sender
{
/Users/Paul/Documents/LPD/Stanford Iphone Courses/CalculatorStanford/Classes/CalculatorStanfordViewController.h:21:0 /Users/Paul/Documents/LPD/Stanford Iphone Courses/CalculatorStanford/Classes/CalculatorStanfordViewController.h:21: error: expected ';' before '{' token
Code:
NSString *digit = [[sender titleLabel] text];
if (userIsInTheMiddleOfTypingANumber)
{
[display setText:[[display text] stringByAppendingString:digit]];
}
else
{
[display setText:digit];
userIsInTheMiddleOfTypingANumber = YES;
}
-(IBAction)operationPressed:(UIButton *)sender
{
if(userIsInTheMiddleOfTypingANumber) {
[[self brain] setOperand: [[display text] doubleValue]];
userIsInTheMiddleOfTypingANumber = NO;
}
NSString *operation = [[[sender titleLabel]text];
double result= [[self brain] performOperation:operation];
[display setText:[NSString stringWithFormat:@"%g", result]];
@end
Below is the m. file.
Code:
#import "CalculatorStanfordViewController.h"
@implementation CalculatorStanfordViewController
-(CalculatorBrain *) brain
{
if (!brain) brain = [[CalculatorBrain alloc] init];
return brain;
}
-(IBAction)digitPressed:(UIButton *)sender
{
}
-(IBAction)operationPressed:(UIButton *)sender
{
NSString *operation = [[sender titleLabel]text];
double result = [[self brain] performOperation:operation];
[display setText:[NSString stringWithFormat:@"%g", result]];
}
@end