i've followed the cocoa currency converter tutorial from the apple web site and i've managed to build it fine, but when i run it i get strange results for my currency conversions. i was wondering if you would be able to recognise what the problem is
here is the code i put into the files:
ConverterController.m
ConverterController.h:
Converter.m:
Converter.h:
i didn't get any build errors or warnings for any of these. i've also taken some screenshots of what i did in interface builder to see if there was a problem there
here is the code i put into the files:
ConverterController.m
Code:
#import "ConverterController.h"
#import "Converter.h"
@implementation ConverterController
- (IBAction)convert:(id)sender
{
float rate, currency, amount;
currency = [dollarField floatValue];
amount = [converter convertCurrency:currency atRate:rate];
[amountField setFloatValue:amount];
[rateField selectText:self];
}
@end
ConverterController.h:
Code:
/* ConverterController */
#import <Cocoa/Cocoa.h>
@interface ConverterController : NSObject
{
IBOutlet NSTextField *amountField;
IBOutlet id converter;
IBOutlet NSTextField *dollarField;
IBOutlet NSTextField *rateField;
}
- (IBAction)convert:(id)sender;
@end
Converter.m:
Code:
#import "Converter.h"
@implementation Converter
- (float)convertCurrency:(float)currency atRate:(float)rate {
return currency * rate;
}
@end
Converter.h:
Code:
/* Converter */
#import <Cocoa/Cocoa.h>
@interface Converter : NSObject {}
- (float)convertCurrency:(float)currency atRate:(float)rate;
@end
i didn't get any build errors or warnings for any of these. i've also taken some screenshots of what i did in interface builder to see if there was a problem there