我下載PDF文檔從服務器:如何下載數據保存到設備的文件系統
- (void)downloadSingleDocument:(NSURL *)url
{
[pdfData release];
pdfData = [[NSMutableData alloc] init];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req addValue:@"Basic **************=" forHTTPHeaderField:@"Authorization"];
downloadConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES];
}
- (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data
{
NSLog(@"Connection did receive data");
[pdfData appendData:data];
}
在connectionDidFinishLoading我想保存下載的PDF文件中的文件目錄到文件系統文件名相同,因爲它是在服務器。 做什麼是最好的方法?
「//在您下載數據後,您可以將您的數據從這裏複製到文件系統,並從這裏刪除」您可以詳細描述這個過程嗎?如何將它複製到文件系統然後刪除它? – Oleg 2012-04-26 07:24:22
@ Oleg對不起,延遲迴復。看到這個:http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSFileManagerDelegate_Protocol/Reference/Reference。html#// apple_ref/doc/uid/TP40009948 – Hector 2012-04-26 09:18:37
謝謝!這是我正在尋找的工作解決方案!接受答案! – Oleg 2012-04-26 10:02:33