I am writing an IOS file upload application which has multiple NSUrlConnection
open at a time (each one for one file upload) and want to implement corresponding progress bar for each one of them.
NSUrlConnection
file upload snippet:
NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:request
delegate:self
[urlConnection start];
The delegate method for updating progress bar:
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
self.progressBar.progress += (float)bytesWritten/(float)totalBytesExpectedToWrite;
NSLog(@"it's working: %lf",self.progressBar.progress);
}
Now in this case if I have a separate progress bar for each file upload, is there a way to know which file upload, that is, which NSURLConnection
this delegate corresponds to, so that I can update the correct progress bar accordingly. Is there any property which I can set in NSURLConnection
, which I can access in connection variable in the delegate method?
Thanks.