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 8101889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:05:56+00:00 2026-06-05T23:05:56+00:00

I’m trying to write a simple game based on selecting the correct answer (A

  • 0

I’m trying to write a simple game based on selecting the correct answer (A B or C) from several question like a school test, and count the correct/incorrect answers to set a score.
I can t figure how to use an NSArray to store all the questions and correct answers and how to set a score. My only solution is to create a new View for each question but it sounds me like a bad solution.
Any help will be truly appreciated.
Thanks

ViewController.h

@interface ViewController : UIViewController {

IBOutlet UILabel *numPregunta;
IBOutlet UILabel *pregunta;
IBOutlet UILabel *lblRespuesta1;
IBOutlet UILabel *lblRespuesta2;
IBOutlet UILabel *lblRespuesta3;
IBOutlet UILabel *lblResultado;

IBOutlet UIButton *respuesta1;
IBOutlet UIButton *respuesta2;
IBOutlet UIButton *respuesta3;

}

-(IBAction)btnRespuesta1:(id)sender;
-(IBAction)btnRespuesta2:(id)sender;
-(IBAction)btnRespuesta3:(id)sender;
-(IBAction)nextPregunta:(id)sender;

@end

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController



- (void)viewDidLoad
{

numPregunta.text = @"Question 1";
pregunta.text = @"Question 1 text";
lblRespuesta1.text = @"ANSWER 1";
lblRespuesta2.text = @"ANSWER 2";
lblRespuesta3.text = @"ANSWER 3 ";


[super viewDidLoad];


}

-(IBAction)btnRespuesta1:(id)sender

{
    if(pregunta.text == @"Question 1 text")
{

    lblRespuesta1.textColor = [UIColor redColor];
    lblResultado.text = @"False! ";
    lblResultado.textColor = [UIColor redColor];

}
}


-(IBAction)btnRespuesta2:(id)sender

{
    if(pregunta.text == @"Question 1 text")
    {

        lblRespuesta2.textColor = [UIColor redColor];
        lblResultado.text = @"False! ";
        lblResultado.textColor = [UIColor redColor];

    }

}

-(IBAction)btnRespuesta3:(id)sender

{
if(pregunta.text == @"Question 1 text")
{

    lblRespuesta3.textColor = [UIColor greenColor];
    lblResultado.text = @"Nice! ";
    lblResultado.textColor = [UIColor greenColor];



}

}    



- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end
  • 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-06-05T23:05:57+00:00Added an answer on June 5, 2026 at 11:05 pm

    You can have an array of question say questionsArray, which will contain all questions.Second create array of dictionary which will contain all options and correct result say resultArray contain at 0 index dictionary with keys Answer1, Answer2, Answer3 and result and value will contain corresponding values.Now take one global variable which will store the question number means which question it is displaying, say question0, question1..etc, which is nothing but question index in questionsArray.Say you are displaying question at index 0,then display options corresponding to that index ie 0 as follows:

    NSString *answer1 = [[resultArray objectAtIndex:0] valueForKey:@"Answer1"];
    NSString *answer2 = [[resultArray objectAtIndex:0] valueForKey:@"Answer2"];
    NSString *answer3 = [[resultArray objectAtIndex:0] valueForKey:@"Answer3"];
    

    and say correct answer is answer2, then result key will be 2.
    and provide tag o each button like 1,2 and 3.
    then in Button action you can check whether user has selected correct option or not as follows:

    if(btn.tag == [[resultArray objectAtIndex:0] valueForKey:@"result"])
    {
       //correct answer is selected so increment score.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace

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.