The goal of my app is to calculate two fields that will return in a text box. Unfortunately I'm receiving an error regarding with unknown type field referring to my TotalField.text field. I have two views. One is the home screen which refers to the second view through a button and the second view contains these fields and labels that I'm trying to target.
This is my code.
ViewController.h
// SalaryCalcApp
//
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *Total;
@property (strong, nonatomic) IBOutlet UILabel *HourlyRate;
@property (strong, nonatomic) IBOutlet UILabel *NumberOfHours;
@property (nonatomic, strong) UITextField *TotalField;
@property (nonatomic, strong) UITextField *HourlyRateField;
@property (nonatomic, strong) UITextField *NumberOfHoursField;
@end
ViewController.m
// SalaryCalcApp
//
//
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@synthesize TotalField;
@synthesize Total;
@synthesize HourlyRate;
@synthesize NumberOfHours;
@synthesize HourlyRateField;
@synthesize NumberOfHoursField;
TotalField.text = [ NSString stringWthFormat: @"%i", (HourlyRateField.text.intValue * NumberOfHoursField.text.intValue) ];
@end
The error resides in this code:
TotalField.text = [ NSString stringWthFormat: @"%i", (HourlyRateField.text.intValue * NumberOfHoursField.text.intValue)];
Error Message:
Unknown type name 'TotalField' and Expected identifier or '('
Thank you everyone for your contributions.
Why is that code not nested inside a function?
Put it inside your viewDidLoad