In the past I have use ASIHTTPRequest
but now there is NSURLRequest
. Should we be using the NSURLRequest
now? Are there any disadvantages?
For people reading this now: I ended up using AFNetworking
as mentioned in the answers
https://github.com/AFNetworking/AFNetworking
Thanks,
NSURLConnection
and NSURLRequest
are the provided Cocoa classes for managing connections. In iOS 7, Apple added NSURLSession
.
But I think you'll find AFNetworking
to be a framework that further simplifies network requests (notably complex HTTP requests). If you don't want to use third-party frameworks for any reason, you can use NSURLConnection
and/or NSURLSession
directly. It just takes a little more coding.
If you're looking for a good ASIHTTPRequest
alternative, AFNetworking
is a great candidate.
For information on NSURLConnection
and NSURLSession
see the URL Loading System Programming Guide.
NSURLRequest
has been there since iOS2.0 (see the doc), so it is not precisely new. ASIHTTPRequest
has been discontinued, the last update was on 15th May 2011, so you shouldn't use it. AFNetworking is a delightful networking library for iOS and Mac OS X as described by them self, and really makes your live easier, in my case it is the first framework I include in my network required projects.
Which one you should use?, I think this depends on your requirements, with NSURLRequest
and NSURLConnection
you can do everything, in fact AFNetworking us built on top of NSURLConnection. But how I tell you before, AFNetworking has my upvote.
EDIT post iOS7
If you are targeting iOS7 you should take a look to NSURLSession, check the official documentation, and this tutorial.
EDIT for Swift
Take a look to the Alamofire project for an implementation done in Swift, it is also created by mattt (the main author of AFNetworking).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With