【发布时间】:2011-11-30 04:39:25
【问题描述】:
这是我的代码,它尝试使用 NSURLDownload 下载网页。但它不起作用,它是一个命令行程序。
- (void)startDownloadingURL
{
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/index.html"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// Create the download with the request and start loading the data.
NSURLDownload *theDownload = [[NSURLDownload alloc] initWithRequest:theRequest delegate:self];
if (theDownload) {
// Set the destination file.
[theDownload setDestination:@"/saleh" allowOverwrite:YES];
} else {
// inform the user that the download failed.
NSLog(@"download has failed!");
}
}
【问题讨论】:
-
有什么不好的?它是否打印
download has failed!?您是否实现了任何NSURLDownloadDelegate 方法,例如downloadDidFinish:或download:didFailWithError:? -
它没有给我任何错误!我已经实现了代表,但它们似乎不起作用!我不知道是什么问题。
标签: objective-c download