bra*_*ray 2 iphone networking ios afnetworking
我无法通过AFNetworking取消下载.在我的应用中,用户可以通过这种方式触发单个电影下载:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
//do success stuff
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"Error downloadMovie: %@", error);
}];
[operation start];
Run Code Online (Sandbox Code Playgroud)
这很好.但是如何强制下载停止?我读到了使用这种方法:
cancelAllHTTPOperationsWithMethod
Run Code Online (Sandbox Code Playgroud)
如果我这样使用它,它什么都不做:
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:@"http://www.xyz/mymovie.mp4"];
[client cancelAllHTTPOperationsWithMethod:nil path:@"http://www.xyz/mymovie.mp4"];
Run Code Online (Sandbox Code Playgroud)
什么是取消下载的正确方法?
提前谢谢了.
| 归档时间: |
|
| 查看次数: |
3756 次 |
| 最近记录: |