Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3930848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:17:46+00:00 2026-05-19T23:17:46+00:00

I am creating a quiz app that will display something depending on their results

  • 0

I am creating a quiz app that will display something depending on their results of the quiz. Right now I am stuck at something. The quiz app is simple, 4 answers, and a question. Having each button switch the view to the next question seemed to be too much code, so I came up with this. What if each button, when pressed, would change the question and the answers? How would I do this? Right now, my code for the answer ‘A’ goes like this:

-(IBAction)a {

switch(questionNumber)
{
    case 0:
    {
        question.text = @"How Much Do You Use Suppressed Weapons?";
    }
        break;

    case 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];
    }
        break;
}

}

This isn’t working, so I was hoping to go to the ‘if’ statement path. How exactly would I code this for each letter answer? I was thinking something like this:

-(IBAction)a {
if(questionNumber = 0) {
question.text = @”whatever the question is”;

and then after each question it would add 1 to the question number. and the next time it would be pressed, it would change the question text to something else, and change the labels for the letter answers. Any help would be GREATLY appreciated. Thank You!!!

Related Question: Having more than one if statements in one IBAction in the .m file isn't working

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:17:46+00:00Added an answer on May 19, 2026 at 11:17 pm

    A switch statement should be fine for what you are trying to do, however your syntax is a little off, use this:

    -(IBAction)a {
    
        switch(questionNumber)
        {
            case 0:
                question.text = @"How Much Do You Use Suppressed Weapons?";
                break;
            case 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];
                break;
           default:
                break;
        }
    }
    

    A good example of this can be found here:
    http://www.techotopia.com/index.php/The_Objective-C_switch_Statement


    However, I think a better choice would be to make a question object that has all the properties you need and then have an array of those in the correct order. Then all you need do is pull the question out by index (questionNumber) and map each property to your interface. You could even go so far as to store the values in a plist and read that in so that you can easily edit/add questions on the fly without having to hardcode anything.

    Here is a quick tutorial about Reading a plist into an NSArray. The second example of using NSDictionary objects might be the simplest for you. Each dictionary could be a question with the appropriate properties. Then you can just pull those values out of the dictionary (which you pulled from the Array by index).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a quiz app which has 2 views, MMAppViewController and a subview
I am creating a quiz creation form that requires sections of the form to
I'm looking for a tutorial that outlines creating an online quiz using jQuery, PHP
I'm creating a quiz app with JQuery, JQtouch & Phonegap. The main screen shows
creating a landing page that sends an email when people submit their address. I'd
Creating a patch is very easy in SubVersion, With Tortoise, you right-click and select
While creating classes in Java I often find myself creating instance-level collections that I
I'm making a trivia webapp that will feature both standalone questions, and 5+ question
First off I'm new at programming. I'm creating an app with one navigation bar
I am creating a quiz game and I can't figure out the best way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.