I am making an iPhone app that will generate something based on quiz answers. I want the button for the answer to change the question text and sometimes the button label text.
Background Info:
- ‘a’ is a button
- ‘questionNumber’ is the question number (duh) and it is why the button will change the texts differently each time it is pressed.
Here is the code I am using:
-(IBAction) a
{
questionNumber == 0;
if(questionNumber == 0) {
question.text = @"How Much Do You Use Suppressed Weapons?";
}
questionNumber == 1;
if(questionNumber == 1) {
question.text = @"Do You Like Sleight of Hand?";
answerA.text = @"Yes";
answerB.text = @"No";
[answerC setHidden:YES];
[answerD setHidden:YES];
[answerButton3 setHidden:YES];
[answerButton4 setHidden:YES];
}
}
and this repeats for the other buttons (b,c, and d). I thought it should work, but it doesn’t do the “do you like sleight of hand” question. It just stays at the how much do you use suppressed weapons question. Please Help! I really want to get into xcoding for the iphone.
BTW, I am not sure that the tags for this question are correct.
Related Question: How can I have an IBAction that has more than two 'if' statements?
Try using a
switchstatement withbreaks.