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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:56:08+00:00 2026-06-09T04:56:08+00:00

I am trying to solve my last problem in my app which is the

  • 0

I am trying to solve my last problem in my app which is the biggest for me.

enter image description here

I have this downloadView shown in the screenshot where I download a file/document from a web server through NSURLConnection asynchronously.

All of the view components work perfectly (download button, progressBarView, abortButton) and so on.

When the download starts, the progress bar increments and I can perfectly abort the download by setting the connection to nil and setting the data length to zero.

:: My challenging problem is that ::

when the download is processed in the background and I click on the “BACK” button and navigate back to the firstView and then navigate back to this downloadView, I lose the access to the download. I can no longer abort it or monitor it. The progress bar resets to zero. However, I can still see the download is going and running through NSLog for progressBar.progress.

I think this problem has something to do with retaining views and accessing threads and keeping a downladView alive when pressing on the “back” button.

Sorry for writing too much but I am trying to clarify this issue well.

here is a basic code to show how I am downloading the file.

-(IBAction)downloadButton:(id)sender{
urlLink= @"http://www.example.com/text.pdf";

NSURLRequest *request= [NSURLRequest requestWithURL:[NSURL URLWithString:urlLink] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];

connectionbook = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
// using the regular delegate connectino methods
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{}
  • 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-09T04:56:09+00:00Added an answer on June 9, 2026 at 4:56 am

    The core problem is that when you hit the Back button, the view controller object gets dealloc’d (or it should), and when you revisit that view, you get another view created from scratch.

    So you have a couple of options. Have the view which you go back to keep a strong reference, so your view shown here is never really dealloced. Thus you always push the same object. You will need to keeps some state around to deal with the viewWillAppear etc getting called all the time.

    The other solution is to have some other persistent object keep the connection and have some way for your view controller showing progress access the information.

    Two other comments. You sadi “I can perfectly abort the download by setting the connection to nil and setting the data length to zero”, which is not the right way to do it. When you want to stop a connection, you send it [conn cancel], then conn.delegate – nil, then you can release it.

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

Sidebar

Related Questions

I have been trying to understand and solve this problem for the last three
I have an interesting problem here I've been trying to solve for the last
I am trying to solve this problem http://www.spoj.pl/problems/PEBBMOV/ . I think I have the
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
Trying to solve this problem . I would like to learn how the bootstrapper
I'm trying to solve the following problem in Redis. I have a list that
I am trying to solve the following problem with Puppet: I have multiple nodes.
i'm almost there but I'm not able to solve the last problem. I'm trying
I'm trying to solve a problem that, unfortunately, goes beyond my capacity. I have
I've been trying to solve this problem all day. I just want to list

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.