cocoa - 在 cocoa Web View 中进行 nsurldownload 后,nsprogressindicor 进度未完全完成

标签 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];
     }

最佳答案

有效负载到底声明为什么?我使用了类似的代码,声明了 NSMutableData *payload ,然后在 -(void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response 中使用了 payload=[NSMutableData data] 而不是您的 payload=0,也许这就是问题所在?

关于cocoa - 在 cocoa Web View 中进行 nsurldownload 后,nsprogressindicor 进度未完全完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16167200/

相关文章:

ios - iOS应用中的同步vs异步调用

cocoa - NSStatusItem 中的 NSProgressIndicator

cocoa - 从另一个包加载资源

objective-c - 如何使用UCKeyTranslate

ios - NSURLSession 委托(delegate) didCompleteWithError 未调用

cocoa - 如何使用确定的 NSProgressIndicator 来检查 NSTask 的进度? - cocoa

objective-c - 通过 Cocoa 连接到 Sharepoint

macos - Cocoa:如何发送正确的鼠标增量事件?

php - 使用ios上传图片到php