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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:11:43+00:00 2026-05-14T04:11:43+00:00

I am using this code: NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self]; to download a file,

  • 0

I am using this code:

NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self];

to download a file, and I want to update a progress bar on a subview that I load. For that, I use this code:

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [oReceivedData appendData:data];
 float n = oReceivedData.length;
 float d = self.iTotalSize;
 NSNumber *oNum = [NSNumber numberWithFloat:n/d];
 self.oDPVC.oProgress.progress = [oNum floatValue];
}

The subview is oDPVC, and the progress bar on it is oProgress. Setting the progress property does not update the control.

From what I have read on the Web, lots of people want to do this and yet there is not a complete, reliable sample. Also, there is much contradictory advice. Some people think that you don’t need a separate thread. Some say you need a background thread for the progress update. Some say no, do other things in the background and update the progress on the main thread.

I’ve tried all the advice, and none of it works for me.

One more thing, maybe this is a clue. I use this code to load the subview during applicationDidFinishLaunching:

self.oDPVC = [[DownloadProgressViewController alloc] initWithNibName:@"DownloadProgressViewController" bundle:nil];
[window addSubview:self.oDPVC.view];

In the XIB file (which I have examined in both Interface Builder and in a text editor) the progress bar is 280 pixels wide. But when the view opens, it has somehow been adjusted to maybe half that width. Also, the background image of the view is default.png. Instead of appearing right on top of the default image, it is shoved up about 10 pixels, leaving a white bar across the bottom of the screen.

Maybe that’s a separate issue, maybe not.

  • 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-05-14T04:11:44+00:00Added an answer on May 14, 2026 at 4:11 am
    self.oDPVC.oProgress.progress = [oNum floatValue];
    

    Setting the progress property does not
    update the control.

    What is the value of self.oDPVC (is it nil)?

    What is the value of self.oDPVC.oProgress (is it nil)?

    A couple of other points.

    First:

    self.oDPVC = [[DownloadProgressViewController alloc] initWithNibName:@"DownloadProgressViewController"bundle:nil];
    

    How is your oDPVC @property defined? If it uses retain, this line could (will) later result a memory leak (it will be double retain-ed). You should use this pattern instead:

    DownloadProgressViewController* dpvc = [[DownloadProgressViewController alloc] initWithNibName:@"DownloadProgressViewController" bundle:nil];
    self.oDPVC = dpvc;
    [dpvc release];
    

    Second:

    float n = oReceivedData.length;
    float d = self.iTotalSize;
    NSNumber *oNum = [NSNumber numberWithFloat:n/d];
    self.oDPVC.oProgress.progress = [oNum floatValue];
    

    The progress property is a float itself. You don’t really need to use an NSNumber object. You also might want to consider adding one to the denominator to avoid divide-by-zero:

    float n = oReceivedData.length;
    float d = self.iTotalSize;
    float percentCompleted = n/(d + 1.0f);
    self.oDPVC.oProgress.progress = percentCompleted;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 365k
  • Answers 365k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the data in the /proc filesystem to… May 14, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer Do you still get the error when you use a… May 14, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer You can use array_chunk to create a single array comprised… May 14, 2026 at 3:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.