Quote:
Originally Posted by wilky94
I have checked that all the questions are the same. this is all the code i have.
Code:
- (IBAction)A:(UIButton *)sender {
result.text = @"Correct";
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] + 1)];
NSLog(question.text);
if ([question.text isEqualToString:@"What was the first programmable computer called?"]) {
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] - 1)];
result.text = @"Incorrect";
}
}
- (IBAction)B:(UIButton *)sender {
result.text = @"Incorrect";
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] - 1)];
if ([question.text isEqualToString:@"What was the first programmable computer called?"]) {
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] + 1)];
result.text = @"Correct";
}
}
- (IBAction)C:(UIButton *)sender {
result.text = @"Incorrect";
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] - 1)];
if ([question.text isEqualToString: @"What was the first programmable computer called?"]) {
result.text = @"Incorrect";
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] - 1)];
}
}
- (IBAction)D:(UIButton *)sender {
result.text = @"Incorrect";
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] - 1)];
if ([question.text isEqualToString: @"What was the first programmable computer called?"]) {
score.text = [NSString stringWithFormat:@"%i", ([score.text intValue] - 1)];
result.text = @"Incorrect";
}
}
- (IBAction)back:(UIButton *)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction)next:(UIButton *)sender {
question.text = @"What was the first programmable computer called?";
answerA.text = @"ZX";
answerB.text = @"Z1";
answerC.text = @"ZZ";
answerD.text = @"Z0";
number.text = @"2";
|
Hi.. I think I may have guessed at what is wrong (or not wrong rather).
I see you are adding the score before the if statement (see the Red fonts i highlighted above). I think the question is detected, but since u are +1 to the score before the if statement, so after the IF STATEMENT is TRUE, it would -1 to score again which sums up to, 0. So no changes in the score was made.
I may be wrong though.. Is that line correct? Seems a bit weird for me.