问题描述
我见过几次使用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:
-
ASIHTTPRequest
允许为每个请求指定一个委托(相对于整个NSURLConnection
的一个委托);这很有用,因为一旦获得了等待的数据,每个请求原则上都有不同的处理;
ASIHTTPRequest
allows to specify a delegate for each request (vs. one delegate for a wholeNSURLConnection
); 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
提供更好的可达性实现,这是绝对必要的;苹果提供的一个是。
ASIHTTRequest
offers a better implementation of Reachability, which is absolutely necessary; the Apple provided one is said to be buggy.
希望这有帮助。
这篇关于为什么我更喜欢ASIHTTPRequest而不是NSURLConnection从网上下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!