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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:58:43+00:00 2026-06-16T16:58:43+00:00

I have a case like this: My app need to upload images to server,

  • 0

I have a case like this:
My app need to upload images to server, and i want to show the upload status to user.
For example, i choose 4 images, and when app is uploading image one, the hud text lable should show “Uploading image 1/4”
when upload image 2,
show “Uploading image 2/4”, etc.
i do not want to place the upload process in the backend, so let’s say the upload process is excuted in main thread. Due to this, the main thread will be blocked when upload images. So the hud thing will not work immediately. how to fix this, can anyone help?
my code is like this:

        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        hud.dimBackground = YES;
        hud.labelText = @"";
        //show the hud
        for (int i = 0;i<[self.images count];i++) {
            hud.labelText = self.maskTitle;//change hud lable text
            [self uploadImage:i];//upload image, this would take long, will block main thread
        }
  • 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-16T16:58:45+00:00Added an answer on June 16, 2026 at 4:58 pm

    You should never perform heavy operations on the main thread, but if you really want to you can to something like

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.dimBackground = YES;
    hud.labelText = @"";
    //show the hud
    for (int i = 0;i<[self.images count];i++) {
        hud.labelText = self.maskTitle;//change hud lable text
        [self performSelector:@selector(uploadImage:) withObject:@i afterDelay:0.001];        
    }
    

    Inserting a delay will allow the NSRunLoop to complete its cycle before you start uploading the images, so that the UI will be updated. This is because UIKit draws at the end of the current iteration of the NSRunLoop.

    An alternative would be to run the NSRunLoop manually, for instance

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.dimBackground = YES;
    hud.labelText = @"";
    //show the hud
    for (int i = 0;i<[self.images count];i++) {
        hud.labelText = self.maskTitle;//change hud lable text
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantPast]];
        [self performSelector:@selector(uploadImage:) withObject:@i afterDelay:0];        
    }
    

    Please not that in both examples your uploadImage: method is now required to accept a NSNumber instead of an int.

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

Sidebar

Related Questions

So I have a Rails app (which in this case seems like it would
I have a switch case like this switch($filesize_in_bytes){ case 10Mb <= $filesize_in_bytes <= 100Mb:
I have a collection testcase like this, Test Builds have many Test Case Logs
I have this use case of an xml file with input like Input: <abc
I have a .NET app that allows a user to choose their own language
I have a route in my code that looks like this: map.app 'applications/:title_header', :controller
I want to create a live, checkers-like app, which will work like this: There
I'm working on a Node.js app (it's a game). In this case, I have
I have case where the class hierarchy is something like this, +---------------+ | UIElement
I have a bulk of data in my app. I need it in case

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.