I have a class which handled the downloads and provides progress information.
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[recievedData appendData:data];
self.recievedlength 开发者_StackOverflow社区= self.recievedlength + [data length];
// Calculating progress
self.progress = 0;
self.progress = ((float)recievedlength / [filesize floatValue]);
// NSLog(@"%f",self.progress);
[self performSelectorOnMainThread:@selector(passProgress) withObject:nil waitUntilDone:NO];
I have the following selector which returns the progress information int form of float, in the same class :
- (float) passProgress { //NSLog(@"%f",self.progress); return self.progress; }
My Question is, how do I update the UIProgressView (progress bar) in the MainViewController. The following does not work.
NSLog(@"Progress %f",[classInstance passProgress]);
Any ideas thanks. I do not want to write the download code in the MainViewController.
Write a protocol
in your download manager. Adopt that protocol in your main view controller.
精彩评论