我正在尝试使用 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 视图中打开它,那就太好了。
谢谢