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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:49:31+00:00 2026-06-02T01:49:31+00:00

I am simply just trying to update my score in the ‘score’ nsmutable array

  • 0

I am simply just trying to update my score in the ‘score’ nsmutable array which was defined in the (id) type function called when my app is run. So I have no clue what is going wrong, I put in a NSLog before the body of the function and after to check what is happening and I will post them after the code.

-(void)changeScore:(int)moves AtLevel:(int)theLevel{
for (int i = 0; i < 20; i++) {
    NSLog(@"At level %d we have a score of: %d ", i+1, [[scores objectAtIndex:i] intValue]);
}
if (theLevel <= 9){
    NSNumber* number = [[NSNumber alloc]initWithInt:50 - moves];
    [scores replaceObjectAtIndex:theLevel - 1 withObject:number];
    NSLog(@"this is number's int value: %d and this is thelevel - 1: %d", [number intValue], theLevel - 1);
}
if (theLevel > 9 && theLevel <= 19){
    NSNumber* number = [[NSNumber alloc]initWithInt:150-moves];
    [scores replaceObjectAtIndex:theLevel - 1 withObject:number];
}
for (int i = 0; i < 20; i++) {
    NSLog(@"At level %d we have a score of: %d", i+1, [[scores objectAtIndex:i] intValue]);
}
}

and the NSLog produces this:

2012-04-14 14:53:49.018 Arctic Defender[2068:f803] At level 1 we have a score of: 0 
2012-04-14 14:53:49.022 Arctic Defender[2068:f803] At level 2 we have a score of: 0 
2012-04-14 14:53:49.023 Arctic Defender[2068:f803] At level 3 we have a score of: 0 
2012-04-14 14:53:49.024 Arctic Defender[2068:f803] At level 4 we have a score of: 0 
2012-04-14 14:53:49.026 Arctic Defender[2068:f803] At level 5 we have a score of: 0 
2012-04-14 14:53:49.027 Arctic Defender[2068:f803] At level 6 we have a score of: 0 
2012-04-14 14:53:49.028 Arctic Defender[2068:f803] At level 7 we have a score of: 0 
2012-04-14 14:53:49.029 Arctic Defender[2068:f803] At level 8 we have a score of: 0 
2012-04-14 14:53:49.030 Arctic Defender[2068:f803] At level 9 we have a score of: 0 
2012-04-14 14:53:49.031 Arctic Defender[2068:f803] At level 10 we have a score of: 0 
2012-04-14 14:53:49.032 Arctic Defender[2068:f803] At level 11 we have a score of: 0 
2012-04-14 14:53:49.033 Arctic Defender[2068:f803] At level 12 we have a score of: 0 
2012-04-14 14:53:49.035 Arctic Defender[2068:f803] At level 13 we have a score of: 0 
2012-04-14 14:53:49.036 Arctic Defender[2068:f803] At level 14 we have a score of: 0 
2012-04-14 14:53:49.101 Arctic Defender[2068:f803] At level 15 we have a score of: 0 
2012-04-14 14:53:49.102 Arctic Defender[2068:f803] At level 16 we have a score of: 0 
2012-04-14 14:53:49.103 Arctic Defender[2068:f803] At level 17 we have a score of: 0 
2012-04-14 14:53:49.104 Arctic Defender[2068:f803] At level 18 we have a score of: 0 
2012-04-14 14:53:49.104 Arctic Defender[2068:f803] At level 19 we have a score of: 0 
2012-04-14 14:53:49.105 Arctic Defender[2068:f803] At level 20 we have a score of: 0 
2012-04-14 14:53:49.106 Arctic Defender[2068:f803] this is number's int value: 38 and this is thelevel - 1: 0
2012-04-14 14:53:49.111 Arctic Defender[2068:f803] At level 1 we have a score of: 0
2012-04-14 14:53:49.112 Arctic Defender[2068:f803] At level 2 we have a score of: 0
2012-04-14 14:53:49.113 Arctic Defender[2068:f803] At level 3 we have a score of: 0
2012-04-14 14:53:49.114 Arctic Defender[2068:f803] At level 4 we have a score of: 0
2012-04-14 14:53:49.114 Arctic Defender[2068:f803] At level 5 we have a score of: 0
2012-04-14 14:53:49.135 Arctic Defender[2068:f803] At level 6 we have a score of: 0
2012-04-14 14:53:49.136 Arctic Defender[2068:f803] At level 7 we have a score of: 0
2012-04-14 14:53:49.137 Arctic Defender[2068:f803] At level 8 we have a score of: 0
2012-04-14 14:53:49.138 Arctic Defender[2068:f803] At level 9 we have a score of: 0
2012-04-14 14:53:49.157 Arctic Defender[2068:f803] At level 10 we have a score of: 0
2012-04-14 14:53:49.159 Arctic Defender[2068:f803] At level 11 we have a score of: 0
2012-04-14 14:53:49.160 Arctic Defender[2068:f803] At level 12 we have a score of: 0
2012-04-14 14:53:49.160 Arctic Defender[2068:f803] At level 13 we have a score of: 0
2012-04-14 14:53:49.163 Arctic Defender[2068:f803] At level 14 we have a score of: 0
2012-04-14 14:53:49.165 Arctic Defender[2068:f803] At level 15 we have a score of: 0
2012-04-14 14:53:49.166 Arctic Defender[2068:f803] At level 16 we have a score of: 0
2012-04-14 14:53:49.167 Arctic Defender[2068:f803] At level 17 we have a score of: 0
2012-04-14 14:53:49.169 Arctic Defender[2068:f803] At level 18 we have a score of: 0
2012-04-14 14:53:49.170 Arctic Defender[2068:f803] At level 19 we have a score of: 0
2012-04-14 14:53:49.171 Arctic Defender[2068:f803] At level 20 we have a score of: 0

EDIT: this is my score initalize code:

-(id)initNewScores{
//Initalize 20 levels
for (int i = 0; i < 20; i++) {
    NSNumber* numb = [[NSNumber alloc] initWithInt:0];
    [scores addObject:numb];
    [numb release];
}
return self;
}
  • 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-02T01:49:32+00:00Added an answer on June 2, 2026 at 1:49 am

    Show the value of scores on entry to that method. I bet it is nil. I.e. whatever you are using to initialize that mutable array isn’t working.

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

Sidebar

Related Questions

i'm trying to make a very simple YACC parser on Pascal language which just
I'm trying to update some existing code that normally runs a Perl script which
I am trying to work out how to update some D3.js elements just by
so i am trying to update the score in my game, and the code
I am trying to use the update method for the gridview and its simply
I'm just trying to do a simple text file read in java for my
Just trying to implement a simple audit logging solution with Grails 2.0.2 and it
I am just trying to get my head around simple view switching for the
I have a very simple workflow that is just trying to send an email
i'm fairly new to django and just trying a couple simple experiments to get

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.