【发布时间】:2012-08-03 20:40:32
【问题描述】:
我正在尝试使用 NSUrlConnection 下载文件,将文件保存到文档目录,然后在 web 视图中打开它。
我正在使用代码:
- (IBAction)down:(id)sender {
// create the request
url = [[NSURL alloc]initWithString:urlbox.text];
NSLog(@"%@",url);
NSURLRequest *theRequest=[NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *theConnection;
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
NSMutableData *receivedData;
receivedData=[NSMutableData data];
}
下载文件。如果有人可以给我一些代码来保存文件并在 web 视图中打开它,那就太好了。
谢谢
【问题讨论】:
-
你已经尝试了什么?你有什么问题吗?这不是按需代码服务。
-
我听说这个“google”网站有一个很棒的代码库
标签: iphone xcode uiwebview nsurlconnection nsdocumentdirectory