开发者

ASIHTTPRequest vs NSURLConnection

Just wondering which is faster in terms of performa开发者_高级运维nce and usability? Or if there's anything better out there?


ASIHTTPRequest is just so much better than NSURLConnection it's ridiculous. It's more powerful AND simpler. I recommend it pretty much every time I see a question here related to NSURLConnection.

I don't know of any other http client library. I'm not religious about ASIHTTPRequest--if a better tool came along, I'd use it. But ASI has SO nailed it, it's hard to think of anybody else reinventing that particular wheel.

EDIT Feb 2012: As of a few months ago, ASIHTTPRequest is deprecated and its author recommends using something else. AFNetworking seems a popular choice, though I haven't used it personally.

I mention this here because this question and answer remain popular, and it seems people don't know about this change.


There's some performance information relating to an old version here:

http://allseeing-i.com/ASIHTTPRequest-1.5

It's pretty comparable. I'm not sure if there are any figures for more recent versions.

Note that the most recent ASIHTTPRequest has built in support for caching (which NSURLConnection doesn't) - if you enable that and it's applicable for your use it gets you a major speedup.

ASIHTTPRequest also does a lot of things for you for free; it can transparently handle HTTP Proxy authentication if you want it to, for example.

I pick ASIHTTPRequest over NSURLConnection all the time: for me the caching was the real major advantage, but everything else is certainly nice to have.

If you do decide to use ASIHTTPRequest, do use the latest git master, not the v1.7 release - the latter has some bugs that cause crashing when cancelling requests and a few other issues which are fixed in master.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜