Mit*_*uzz 3 iphone multithreading download ios
我有一个包含不同网址的数组,以及一组按钮,每个按钮都分配给每个按钮.单击按钮时,将下载分配给该特定按钮的URL中的内容.用户可以同时单击多个按钮,以便可以同时执行多个下载.同时,用户应该具有导航到另一个视图的规定,以便下载过程不应该锁定UI.哪个是实现这个的最好和最简单的方法?请分享您的想法.谢谢
只是异步获取数据:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
// The code here is executed when the response from the request comes back.
// The variable "data" will contain the response from the data.
// So you can do something like:
UIImage *anImage = [[UIImage alloc] initWithData:data]];
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1956 次 |
| 最近记录: |