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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:53:48+00:00 2026-06-17T15:53:48+00:00

I am trying to create a scoring for my quiz app. The score is

  • 0

I am trying to create a scoring for my quiz app. The score is a label on my page and I use 3 different pages with a score label. One is the quiz then the correct page and the incorrect page. Initially, I set the value of the label to 0 on the quiz page. Then upon selection of the correct answer, it goes to the corresponding page and updates the score. So from 0 it becomes 1. Then it goes back to the question page with the label currently 1 and should update to 2 when the answer is correct again. My problem is, my label can’t seem to get updated. The score starts out as 0 then add 1 but after that, the score is stuck to 1. Here’s my code for it. I’m pretty sure, there’s a problem with the logic I’m using for it so I really appreciate all the help.

*Question Page

if(score.text == @"")
{
    int i = 0;
    strDefaultScore = [[NSString alloc] initWithFormat:@"%i", i];
    score.text = strDefaultScore;
}
else
{
    CorrectPage *update = [[CorrectPage alloc] init];
    strDefaultScore = update.updateScore;
    score.text = strDefaultScore;
}

Then here’s my code for the CorrectPage

QuestionPage *quiz = [[QuestionPage alloc]init];
int i = 1;
int j = [quiz.strDefaultScore intValue];
int sum = i + j;
updateScore = [[NSString alloc] initWithFormat:@"%i", sum];
currentScore.text = updateScore;

I’ve tried checking the value of strDefaultScore for both pages using NSLog and both return 0 which is why the score is 1 no matter how many correct answers I get. How do I correct this?

I have extremely little to none knowledge in using Objective-C and I’ve been searching the web for help with this but can’t find any so I honestly have no idea how to go about this.

Update:
I’ve managed to figure it out. I moved the code on the event(s) for the buttons so it looks something like this now.

-(IBAction)btn1 {
//Redirect to the next page
CorrectPage *correct = [[CorrectPage alloc]initWithNibName:@"CorrectPage" bundle[NSBundle mainBundle]]; 
[self.navigationController pushViewController: correct animated:YES];

//Update the value of score    
int newScore = [score.text integerValue];
int sum = newScore + 1;
updatedScore = [[NSString alloc]initWithFormat:@"%i", sum];
score.text = updatedScore;

//Pass the value of new score on the next page
[correct.currentScore setText: score.Text];
}

That worked for me but what I did was hardcoded so I had to put this on every button event. Also, since what I did is hard coded, I’m pretty much sure that there a better way of doing it.

  • 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-17T15:53:49+00:00Added an answer on June 17, 2026 at 3:53 pm

    Look closely at this code in the else condition:

    CorrectPage *update;
    strDefaultScore = update.updateScore;
    score.text = strDefaultScore;
    

    Your update object is not initialized, so it cannot respond to any messages. This would be better:

    CorrectPage *update = [[CorrectPage alloc] init];
    

    But you would need to set the updateScore value somehow.

    Also, QuestionPage *quiz; has the same problem.

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

Sidebar

Related Questions

Trying to create a facebook app just to learn and coming across a strange
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm trying to create an app where the authorization part is done by checking
I am trying to create an app which will allow a user to view
I am trying to calculate a special score. The 'total' and the 'correct' (or
I'm trying to create a simple MVC 4 app with a few buttons that
I am trying to create a widget called SiteAlert that appears on pages with
I am trying to create a simple quiz of simple addition. I wanted to
I am trying to create a Unidirectional one-to-one relationship using NHibernate. Example: An Order
I'm trying to create a system in Python in which one can select a

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.