0

I'm trying to return the value of "totaal" in an NSLog() message. If I put all the code in the - (IBAction)txtChangeEinde:(id)sender it works fine, I'm just trying to figure out how those methods and classes work.

@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]);


}

Sample Code (image)

Verbe
  • 634
  • 7
  • 13
  • Why does the `berekenTotaal` method take a `float` parameter? The value is not used in the implementation of the method. – rmaddy Jul 19 '13 at 04:55
  • @maddy well, i'm wondering if the entire idea of the methods and classes are correct. So if you have some fine-tuning and global line extra's. I'd be great! – Verbe Jul 19 '13 at 04:58

1 Answers1

0

call like this,

- (IBAction)txtChangeEinde:(id)sender {

    NSLog(@"totaal: %.2f",[self berekenTotaal:totaal]);   OR

    NSLog(@"totaal: %.2f",[self berekenTotaal:someFloatValue]);


}
Balu
  • 8,470
  • 2
  • 24
  • 41