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

查看:87
本文介绍了为什么我更喜欢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 提供更好的可达性实现,这是绝对必要的;苹果提供的一个是据说是有缺陷的

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天全站免登陆