在cocoa webview中的nsurldownload之后,nsprogressindictor进度没有完全完成

时间:2013-04-23 10:37:10

标签: cocoa nsurlconnection nsprogressindicator nsurldownload

我的进度指示器在cocoa webview中不起作用我使用了这段代码 -

   -(void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response { 
                 NSLog(@"downl didreceiveresponse here"); 
                 NSLog(@"Recieved reponse with expected length: %lli", [response expectedContentLength]); 
                payload=0; 
                [payload setLength:0]; 
                [progrssbar setMaxValue:[response expectedContentLength]] ; 
                [self setProgrssbar:progrssbar]; 
        } 
            - (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data 
        { 
              NSLog(@"Recieving data. Incoming Size: %li Total Size: %li", (unsigned long)[data length], (unsigned long)[payload length]); 
              [payload appendData:data]; 
              [progrssbar setDoubleValue:[payload length]]; 
         } 
  - (void)download:(NSURLDownload *)download didReceiveDataOfLength:(unsigned)length 
   { 
            NSLog(@"downl receivedata here%i",length); 
            [progrssbar setHidden:NO]; 
            [progrssbar setIndeterminate:NO]; 
            [progrssbar startAnimation:self]; 
            [progrssbar setDoubleValue:(double)length]; [progrssbar displayIfNeeded];
     }

1 个答案:

答案 0 :(得分:1)

有效负载究竟是什么声明的?我使用了类似的代码,我声明NSMutableData *payload,然后在-(void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response我使用了payload=[NSMutableData data]而不是payload=0,这可能是问题吗?