I don't actually know Objective C, and I have never attempted to read it before, so this might be thoroughly nonsense, but here goes.
It seems like you've declared a class containing four variables:
Code:
int numberonetomultiply;
int numbertwotomultiply;
int numberone;
int numbertwo;
I'm pretty sure you only want the first two. Especially since you seem to be declaring a setnumberone which takes a variable called "numberone" as its parameter. You never use the numberone in the class and you have a name collision there.
And you haven't declared numberone or numbertwo inside main() at all, just inside the class. Just to be clear, member variables exist once the class is instantiated, and a copy of the variables exists for each instance of the class. I think you want to declare numberone and numbertwo inside main(), or (gasp) as global variables. Hence my suggested modifications are:
Code:
#import <Foundation/Foundation.h>
#import <stdio.h>
@interface calculator : NSObject
{
int numberonetomultiply;
int numbertwotomultiply;
int result;
}
-(void) disp;
-(void) setnumberone: (int) numberone;
-(void) setnumbertwo: (int) numbertwo;
-(void) runcalc;
@end
@implementation calculator
-(void) disp
{
printf("\n%i multiplied by %i yields %i\n", numberonetomultiply, numbertwotomultiply, result);
}
-(void) setnumberone: (int) numberone
{
numberonetomultiply = numberone;
}
-(void) setnumbertwo: (int) numbertwo
{
numbertwotomultiply = numbertwo;
}
-(void) runcalc
{
result = (numberonetomultiply * numbertwotomultiply);
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int numberone;
int numbertwo;
NSLog (@"This program is a calculator that multiplies two numbers.");
NSLog (@"Input first number,then press enter\n");
calculator *humaninput = [calculator new];
scanf ("%i", &numberone);
printf("Now type the second number, then press enter\n");
[humaninput setnumberone: numberone];
scanf ("%i", &numbertwo);
[humaninput setnumbertwo: numbertwo];
[humaninput runcalc];
printf("\nDisplaying answer...\n");
[humaninput disp];
[pool drain];
return 0;
}
Let me know if it compiles . . .