내가 당신 대신 당신이 여러 부분으로 다운로드를 얻을 수 있도록 큰 파일을 다운로드하는 경우 사용자 NSURLMutableRequest하려고한다고 생각합니다. NSURLResponse의 expectedContentLength 메소드를 사용하여 파일 길이를 알 수 있습니다.
- (void)connection:(NSURLConnection *)connection
didReceiveResponse : (NSURLResponse *) 응답 {
NSLog (@"%d", [response expectedContentLength]);
}
- (void)connection:(NSURLConnection *)connection
didReceiveData:(NSData *)data {
if (self.currentDownloadedFile) {
[self.currentDownloadedFile seekToEndOfFile];
[self.currentDownloadedFile writeData:data];
}
}
- (void)connectionDidFinishLoading:(NSURLConnection*)connection {
// Close the file here
}
다음 예는
강제로 UIWebView가 다운로드 된 파일을 un URL에서 다운로드하는 대신 강제로 엽니 다.