Add two number and display

Well, I can press a button (called calculate) and add two int numbers if they are constants. But, if I try to get input from textfields and add them, I get zero for the answer.

I tried setting the textfields as outlets - didn't help. Here's the .m code snippet:

int xIn1, xIn2; // declare variables

- (IBAction)calculate:(id)sender {

xIn1 = [TextField1 intValue]; // if = constant, it works
xIn2 = [TextField2 intValue];

[resultY setIntValue: (xIn1 + xIn2)];
}

Any help is appreciated - thanks!
@end

Submitted by Anonymous (not verified) on Tue, 12/01/2009 - 01:04.

Reply

The content of this field is kept private and will not be shown publicly.
Enter the code shown in the image:

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 13 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Donate!





If you like what you find here and wish to support further development of this site, please donate via PayPal. No account required.

Syndicate

Syndicate content

User login

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
10 + 7 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Enter the code shown in the image: