Aborting, montitoring a download after navigating away, thread issue?
===

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

![enter image description here][1]

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]: http://i.stack.imgur.com/aJD9r.png