Quote:
Originally Posted by rocotilos
Hi. Maybe u can do it like this:
Code:
- (IBAction)A:(UIButton *)sender {
if ([question.text isEqualToString:@"What was the first programmable computer called?"]) {
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] - 1)];
result.text = @"Incorrect";
return;
}
result.text = @"Correct";
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] + 1)];
NSLog(question.text);
}
So if the result is wrong, it would deduct 1 point from score and exit the method (using return). Then all the green code is ignored. If it is right, the if statement is ignored, and the green code is executed. I probably use a complete if..else statement.. but im not sure how ur game work. Give the above code a try.
|
now it is not adding 2 but still adding 1 instead of taking away 1.