2011-09-19 48 views

回答

0

你應該能夠得到您的NSURLConnection的的委託預期的內容長度

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 
    contentLength = [response expectedContentLength]; 
     downloadedContentLength = 0; 
... 
} 

然後跟蹤的部分的長度,你已經在

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 
    downloadedContentLength += [data length]; 
    int percentage = ((double)downloadedContentLength/contentLength)*100 
+0

'expectedContentLength'獲得-1 –

相關問題