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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:55:53+00:00 2026-06-06T14:55:53+00:00

Would anyone know why the bmlabel is not updated? and the log score shows

  • 0

Would anyone know why the bmlabel is not updated? and the log “score” shows nothing? Without GCD, it works fine, but it blocks the ui (i would like to show the numbers between 100 to 500 for example, showing 101, 102…499, 500 very fast, instead of going directly from “100” to “500”). So i wanted to use another thread to calculate it, even if i’m not sure it’s the best way. Here’s my code :

//in .h, i imported :
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


//in .m
@implementation ScoreLayer

-(void)updateScore:(int)num{
    CCLOG(@"hello");
    int newScore = score+num;
    //dispatch_queue_t queue = dispatch_queue_create("Test", 0);
    dispatch_queue_t main = dispatch_get_main_queue();
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);

    dispatch_async(queue, ^{
        for (int i=score; i< newScore; i++){
            score++;
            CCLOG(@"score:%i", score);
            NSString *str = [NSString stringWithFormat:@"%d", score];

            dispatch_async(main, ^{
                [bmlabel setString:str];
            });

        }
    });
    score = newScore;
}

-(id) init
{
    if( (self=[super init])) {
        bmlabel = [CCLabelBMFont labelWithString:@"14763" fntFile:@"TestFont.fnt"];
        bmlabel.anchorPoint = ccp(0, 0.5f);
        bmlabel.position = ccp(0,250.0f);
        [self addChild:bmlabel z:200]; 
            score = 14763;
    }
    return self;
}

Thanks a lot

  • 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-06T14:55:54+00:00Added an answer on June 6, 2026 at 2:55 pm

    I assume that score property is a __block type because you’re changing it inside block in line:

     score++;
    

    because your block is executed with dispatch_async main loop continues execution and most likely encounters score = newScore; before your block even starts. When your block is about to run, score is already equal newScore and your loop’s will never work, because its condition expression will return false. In:

    for (int i=score; i< newScore; i++)
    

    i will equal to newScore and because newScore < newScore is false, your loop will never run.

    I suggest to delete last line in your updateScore: method.

    score = newScore;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of a C# spell check library that would underline misspelled works
I like the way ASDM on a ASA5505 works very much. Would anyone know
Would anyone know how to test for the appearance of a Toast message on
I am using double[] instead of NSArray. Would anyone know how to encode it
Would anyone one know if Apple has restrictions on providing a user feedback/bug report
Would anyone happen to know a trick that will keep this MSBuild task from
Does anyone know of a library that would allow me to manipulate Flex DOM
Does anyone know how I would go about changing (transforming) an image based on
Does anyone know a script which would wrap old Products namespace style Plone add-on
Does anyone know the display formatter that I would need to add to the

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.