BUG出現(xiàn)
以前用NSURLSessionDownloadTask
做的一個(gè)偽斷點(diǎn)續(xù)傳下載窒盐,使用很長(zhǎng)時(shí)間后由于服務(wù)器文件的遷移萝招,下載功能的進(jìn)度出現(xiàn)了問題。
BUG原因
后來debug
發(fā)現(xiàn)downloadTask
中的response
中返回的content length
參數(shù)沒有殖熟。所以才導(dǎo)致了無法獲取下載文件的總大小問題。
確認(rèn)問題
只用在如下代理方法中查看response
內(nèi)容即可。
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
NSLog(@"%@",downloadTask.response);
}