I’m creating a quiz app, and I was wondering instead of using multiple if statements, I could make an algorithm that uses an int to alternate between UIViews when you click a UIButton. With multiple if statements the code would look something like this:
IBAction NextQuestion; {
Question++; //QUESTION IS THE int FOR THE ALGORITHM.
if (Question==2) {
self.view = PlayView2; //PlayView2 is the UIView I'm switching to.
}
if (Question==3) {
self.view = PlayView3; //PlayView3 is the UIView I'm then switching to after the next object/UIButton is pressed.
}
and so on…
The IBAction is connected to multiple UIButtons to change the view. The goal is I want to change the UIView algorithmically instead of multiple if statements Thanks for your help!
1 Answer