Reputation: 7517
I did every thing, at least I tried to do everything JUST like the tutorial, but it gives me now 5 errors and 1 warning...
I am just beginning with Objective-c, so please explain your solutions.
Here's my code: (Errors marked and described in comments)
CalculatorViewController.h:
//
// CalculatorViewController.h
// Calculator
//
// Created by Me on 06-04-12.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CalculatorViewController : UIViewController {
IBOutlet UILabel *display;
CalculatorBrain *brain; // error: "Expected specifier-qualifier-list before 'CalculatorBrain':
NSString *waitingOperation;
}
- (IBAction)digitPressed: (UIButton *)sender;
- (IBAction)operationPressed: (UIButton *)sender;
@end
CalculatorViewController.m:
//
// CalculatorViewController.m
// Calculator
//
// Created by Me on 06-04-12.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#import "CalculatorViewController.h"
@implementation CalculatorViewController
- (CalculatorBrain *) brain { // error: "Expected ')' before 'CalculatorBrain'"
if (!brain) { // error: "'brain' undeclared"
brain = [[CalculatorBrain alloc] init]; // error: "'CalculatorBrain' undeclared"
}
return brain;
} // warning: Control reaches end of non-void function
-(IBAction)digitPressed:(UIButton *)sender {
if ([waitingOperation isEqualToString:@""]) {
NSString *digit = [[sender titleLabel] text];
[display setText:digit];
}
else {
// Do calculations if everything works, now just log something to check if it works
NSLog(@"Joepie!");
}
}
-(IBAction)operationPressed:(UIButton *)sender {
}
- (void)dealloc {
[super dealloc];
}
@end
Upvotes: 1
Views: 94
Reputation: 726967
You are missing
#import "CalculatorBrain.h"
at the top of your .h file.
Upvotes: 4