为什么我应该更喜欢 ASIHTTPRequest 而不是 NSURLConnection 从网络下载文件? [英] Why should I prefer ASIHTTPRequest over NSURLConnection for downloading files from the web?

查看:34
本文介绍了为什么我应该更喜欢 ASIHTTPRequest 而不是 NSURLConnection 从网络下载文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过几次有人使用 ASIHTTPRequest 下载文件.现在我想知道为什么?与 NSURLConnection 相比有哪些核心优势?

I've seen a couple of times people using ASIHTTPRequest to download files. Now I wonder why? What are the core benefits over NSURLConnection?

推荐答案

有几个原因.在我看来,这些是主要的:

There are several reasons. In my mind these are the major ones:

  1. ASIHTTPRequest 允许为每个请求指定一个委托(相对于整个 NSURLConnection 的一个委托);这很有用,因为原则上每个请求都会在获得等待的数据后进行不同的处理;

  1. ASIHTTPRequest allows to specify a delegate for each request (vs. one delegate for a whole NSURLConnection); this is useful because each request has in principle a different processing once you get the data you were waiting for;

ASIHTTPRequest 支持缓存机制,可以让您的应用在离线时轻松运行(并显示缓存数据);NSURLRequest 中没有这种机制;

ASIHTTPRequest supports a caching mechanism that make very easy to make your app working when offline (and showing the cached data); no such mechanism in NSURLRequest;

如果你搜索 stackoverflow,你会发现很多关于奇怪的内存泄漏的提示NSURLConnection/NSURLRequest 引起的;ASIHTTRequest;

If you search stackoverflow, you will find many hints at a very strange memory leak that NSURLConnection/NSURLRequest provoke; this is not experienced with ASIHTTRequest;

ASIHTTRequest 提供了更好的 Reachability 实现,这是绝对必要的;Apple 提供的是 据说有问题.

ASIHTTRequest offers a better implementation of Reachability, which is absolutely necessary; the Apple provided one is said to be buggy.

希望这会有所帮助.

这篇关于为什么我应该更喜欢 ASIHTTPRequest 而不是 NSURLConnection 从网络下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆