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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:12:31+00:00 2026-06-03T22:12:31+00:00

at some point in my apps, i put a list of code that requires

  • 0

at some point in my apps, i put a list of code that requires the app to get data from server, knowing this process might takes quite some time, i decide to put a loading notification where the screen darken and i put a label in the center of it saying “now loading blablabla data from server”

the problem is, in between loading several data from server (JSON data), the label won’t change even if i put the code to change it between the JSON function

here is my code

[self.viewReportProduksi getDataReport];
                           [loadinglabel setText:@"Loading Chart Data from server . . ."];
                           [self.viewReportProduksi getChartData];
                           [loadinglabel setText:@"Loading Data Komisi from server . . ."];
                           [self.viewKomisi getDataKomisi];
                           [loadinglabel setText:@"Loading Bonus Data from server . . ."];
                           [self.viewBonus getDataBonus];
                           [loadinglabel setText:@"Loading Bonus Agen Data from server . . ."];
                           [self.viewBonusAgen getDataBonusAgen];
                           [loadinglabel setText:@"Loading Agent Reward Data from server . . ."];
                           [self.viewAgenReward getDataRewardAgen];

those “getXXXXXX” is a method where the JSON is executed.

logically this should make the app show how far have the progress gone. but the label keep stucked at “loading chart data from server” and wont change accordingly to what i code.

i have tried this on both main thread and using dispatch_queue, both shows no differences

thanks

  • 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-03T22:12:32+00:00Added an answer on June 3, 2026 at 10:12 pm

    The problem is that all the graphics updates happen on the main thread. So nothing will change on the display untile the whole of your block of code is complete. I think this is a case where you need to do all the data loading in the background. For maximum flexibility, I would use a load of NSBlockOperations.

    First you need a method to run on the main thread to update your status text.

    -(void) updateStatusWithString: (NSString*) message
    {
        [loadingLabel setText: message];
        // might want to do other stuff e.g. if you have fully loaded the data
    }
    

    Then, instead of your method sequentially loading all the data, create an NSBlockOperation for each phase and bung it on an operation queue.

    -(void) loadData
    {
        NSBlockOperation* block1 = [NSBlockOperation blockOperationWithBlocK: ^()
        {
            [self performSelectorOnMainThread: @selector(updateStatusWithString:)
                                   withObject: @"Loading chart data from server"
                                waitUntilDone: NO];
            [self.viewReportProduksi getChartData];
        }];
        NSOperationQueu* queue = [[NSOperationQueue alloc] init];
        [queue addOperation: block1];
    
        NSBlockOperation* block2 = [NSBlockOperation blockOperationWithBlocK: ^()
        {
            [self performSelectorOnMainThread: @selector(updateStatusWithString:)
                                   withObject: @"Loading Data Komisi from server"
                                waitUntilDone: NO];
            [self.viewKomisi getDataKomisi];
        }];
        [block2 addDependency: block1];
        [queue addOperation: block2];
    
        // etc for all the other blocks
    }
    

    Because each operation has a dependency on the previous operation, they will be executed one after the other, but on some background thread. Using operations and operation queues has an advantage over GCD because

    • you can easily model dependencies between operations using -addDependency:
    • operations have a built in mechanism for cancellation. If the user decides to quit the app halfway through, you can issue

      [queue cancelAllOperations];
      

      All operations on the queue that haven’t been started will be cancelled.

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

Sidebar

Related Questions

At some point Find All References feature got broken for a single solution that
At some point I must have moved files from one location to another using
I believe I read at some point that due to Android running on the
Possible Duplicate: Calculate age in JavaScript In some point of my JS code I
Please point me to any dupes or better places to post this question that
I'm developing now several iOS apps that shared some common thirdy-party libs, plus some
I have some app ideas that I want to release for free (with ads).
I am doing a one-way data transfer app from MS Access to a Rails
I have an app I am offering for free for now. At some point,
Other posters have previously said in this forum that when your Django app starts

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.