I am using this code:
NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self];
to download the file, and I want to update the progress bar in the sub-item that I am downloading. For this, 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 is oProgress. Setting the progress property does not update the control.
From what I read on the Internet, many people want to do this, but still there is no complete and reliable selection. In addition, there are many conflicting tips. Some people think that you do not need a separate thread. Some say you need a background thread to update the move. Some say no, do other things in the background, and update the main thread.
I have tried all the tips and none of this works for me.
, , . subview applicationDidFinishLaunching:
self.oDPVC = [[DownloadProgressViewController alloc] initWithNibName:@"DownloadProgressViewController" bundle:nil];
[window addSubview:self.oDPVC.view]
XIB ( Interface Builder, ) 280 . , - . , default.png. , , 10 , .
, , , .