我創建了一個具有一個頁面的應用程序,並且在該頁面中存在一個按鈕,該按鈕在點擊時下載了文件。在xcode中使用AFNetworking進行下載文件時出現錯誤
我可以下載文件,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'
「AFURLConnectionOperation *操作」 更改此到「AFHTTPRequestOperation *操作」 – 2013-05-06 13:21:37
我的朋友正確它,但我不從網址下載文件!爲什麼? – emma 2013-05-06 13:28:16