我创建了一个具有一页的应用程序,并且在此页面中存在一个单击时下载文件的按钮。
我可以使用 AFNetworking 下载文件,但出现错误....
这是我的代码:
- (IBAction)downloads:(id)sender
{
NSLog(@"start downloads");
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:
@"http://.../500x333xgalaxy-core-product-image-1tn.jpg,
q1367836642.pagespeed.ic.eafBYU8jUN.jpg"]];
AFURLConnectionOperation *operation = [[AFHTTPRequestOperation alloc]
initWithRequest:request];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent
:@"filename.jpg"];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation,
id responseObject) {
NSLog(@"Successfully downloaded file to %@", path);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
这个错误是:
No visible @interface 'AFURLConnectionOpretion' declares the selector
'setCompletionBlockWithSuccess'