I'm getting an error in currency converter, while I'm sure I typed something wrong somewhere I want to understand my problem better
my ConverterController.m is:
#import "ConverterController.h"
The problem was that I was getting an error on setting the amount field, in the debugger I realized that
[converter convertCurrency:currency atRate:rate];
was returning a pointer, not a float? Which is why I can see it works if I explicitly create a float instead of a pointer to a float. Also would love to know what I did wrong.
My Converter.m is:
I am fluent with java but I'm not sure I understand how the demo was supposed to originally work if the setAmount field expects a float but gets a pointer. Then again in Java, pointers/types are much simpler.
Also, this is an example of messaging right, instead of explicit methods? It seems for a simple demo messaging would be more inherent to tough to spot problems.
thanks
my ConverterController.m is:
#import "ConverterController.h"
Code:
@implementation ConverterController
- (IBAction)convert:(id)sender
{
float rate, currency, amount;
currency = [dollarField floatValue];
rate = [rateField floatValue];
amount = 8;//
id temp = [converter convertCurrency:currency atRate:rate];
[amountField setFloatValue:amount];
[rateField selectText:self];
}
@end
The problem was that I was getting an error on setting the amount field, in the debugger I realized that
[converter convertCurrency:currency atRate:rate];
was returning a pointer, not a float? Which is why I can see it works if I explicitly create a float instead of a pointer to a float. Also would love to know what I did wrong.
My Converter.m is:
Code:
@implementation Converter
- (float)convertCurrency:(float)currency atRate:(float)rate {
float total = currency * rate;
return total;
}
Also, this is an example of messaging right, instead of explicit methods? It seems for a simple demo messaging would be more inherent to tough to spot problems.
thanks