Hello MacRumors,
I'm new here and just started obj - C programming last week. Today I was performing the ritual of trying to create a calculator app using the xcode and userinterface.
I finished but when I debugged, I got some messages that I didn't quite understand.
It was saying that some of my methods were undeclared, which doesn't make sense since I defined them in my @interface section...
Anyways, here's the code
I'm new here and just started obj - C programming last week. Today I was performing the ritual of trying to create a calculator app using the xcode and userinterface.
I finished but when I debugged, I got some messages that I didn't quite understand.
It was saying that some of my methods were undeclared, which doesn't make sense since I defined them in my @interface section...
Anyways, here's the code
Code:
#import "Calculator4_vbaViewController.h"
@implementation Calculator4_vbaViewController
-(CalculatorBrain *)brain
{
if (!brain) {
brain = [[CalculatorBrain alloc] init];
}
return brain;
-(IBAction)digitPressed:(UIButton *)sender;
{
if (userIsInTheMiddleOfTypingANumber) {
[display setText: [[display text] stringByAppendingString:digit]];
} else {
[display setText:digit];
userIsInTheMiddleOfTypingANumber = YES;
}
}
-(IBAction)operationPressed:(UIButton *)sender;
{
NSString *digit = [[sender titleLabel] text];
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
Last edited by a moderator: