开发者

Passing Progress Bar Information to the View Controller

开发者 https://www.devze.com 2023-02-19 21:12 出处:网络
I have a class which handled the downloads and provides progress information. -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消