One Week New Programmer has Questions
Here is the code from my header and corresponding method. I need help (1) converting the integer back to a string so that I can output it to the label (2) or I am wondering if my approach is overly complex, or missing some components. (3) Also if you could refer to me some good introductory tutorials besides those from apple.com,iPhonedevcentral, or cocoadevcentral I would GREATLY appreciate this!
=========HEADER===========
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface Calculator : UIView {
IBOutlet UITextField *field1; //First Text Field
IBOutlet UITextField *field2; //Second Text Field
IBOutlet UILabel *total; /*Label, which will be updated upon clicking the button to add field1&field2*/
}
@property (nonatomic, retain) UITextField *field1; //ability to declare int here?
@property (nonatomic, retain) UITextField *field2; //ability to declare int here?
@property (nonatomic, retain) UILabel *total;
- (IBAction)calculate;
@end
==========END HEADER======
==========METHOD=========
#import "Calculator.h"
@implementation Calculator
@synthesize field1;
@synthesize field2;
@synthesize total;
- (IBAction)calculate {
int intField1 = [field1.text integerValue];
int intField2 = [field2.text integerValue];
int intTotal = intField1 + intField2;
total.text = intTotal; // <<<<<THIS IS WHERE THE PROBLEM LIES
}
@end
========END METHOD===========
Thanks Again,
RK