I am new to iOS development. I am creating a simple app that calculates the payout of a horse bet based on the user's bet placed and the odds they enter for the horse. In XCode (4.6.3), I have the following method which is used to calculate increase the user's bet by 1 when the button is clicked:
-(IBAction) addBet:(id) sender {
self.bet = [_betTextField.text intValue];
if(self.bet > 0) {
self.bet += 1;
self.betTextField.text = [NSString stringWithFormat:@"%d", self.bet];
}
}
I have declared the betTextField variable as follows in my header file: @property (weak, nonatomic) IBOutlet UITextField *betTextField;
XCode gives me an error if I do not use the underscore before the betTextField.text
variable. Why is this?