我正在尝试在NSLog()
消息中返回“totaal”的值。如果我把所有代码都放在- (IBAction)txtChangeEinde:(id)sender
它工作正常,我只是想弄清楚这些方法和类是如何工作的。
@implementation Oak
@synthesize txtEinde,txtBegin,cboSchaal;
- (float)berekenTotaal:(float) totaal{
begin = [txtEinde floatValue];
einde = [txtBegin floatValue];
if (begin<0) {
begin= begin*-1;
}
totaal = begin + einde;
return totaal;
}
- (IBAction)txtChangeEinde:(id)sender {
//where it goes wrong!
NSLog(@"totaal: %.2f",[berekenTotaal totaal]);
}