
AFNetworking 2.0 - matttthompson
https://github.com/afnetworking/afnetworking#readme
======
kreeger
Kudos to Mattt Thompson and the whole community of collaborators that put work
into this release. AFNetworking makes a large part of my job making iOS apps a
joy, and I can't wait to start working with latest round of changes and
features in this new release (including support for NSURLSession in iOS 7).

That said if you haven't used AFNetworking before, I highly recommend doing
so. Start with the AFHTTPRequestOperation class(es). And if you're writing an
API wrapper of any kind, definitely check out subclassing either
AFHTTPRequestOperationManager (for iOS 6) or AFHTTPSessionManager (for iOS 7).

Edit: Derp, I was wrong — AFHTTPClient's been split-up. Thanks for calling me
out, @dcaunt; I've updated my remarks.

[https://github.com/AFNetworking/AFNetworking/wiki/AFNetworki...](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-
Guide#afhttpclient--afhttprequestoperationmanager--afhttpsessionmanager)

~~~
dcaunt
With AFNetworking 2.0, you'll use AFHTTPRequestOperationManager in iOS 6 and
AFHTTPSessionManager in iOS 7 rather than AFHTTPClient.

~~~
kreeger
I glossed over that originally, apologies; I've updated my comment.

------
ianstallings
"Response serializers can also be chained, using AFCompoundSerializer"

 _Does a dance._

"AFNetworking 2.0 introduces AFURLSessionManager, which manages an
NSURLSession object based on a specified NSURLSessionConfiguration object, and
conforms to <NSURLSessionTaskDelegate>, <NSURLSessionDataDelegate>,
<NSURLSessionDownloadDelegate>, and <NSURLSessionDelegate>. Convenience
methods to inspect and cancel tasks are provided, as well as block-based
callback properties for each delegate method"

 _Does another dance_

It just gets better and better.

------
orta
This library is arguably the most used library on CococaPods, and has been
serious refresher for me in terms of what a network API should look like. It
was during a discussion about what AFNetworking did that kickstarted CocoaDocs
so that everyone has easy access to documentation for any Obj-C library.

To bring it back to CocoaPods, Mattt's push towards making sure that CocoaPods
works well with AFNetworking and vice-versa has had a huge benefit on the
community in terms of both showing what the new standard for OSS on Obj-C
should look like and what the best practices for writing apps should be. And I
applaud him for this.

I think AFNetworking is the library that has most raised the sea level that we
all now work at. Thank you Mattt. If I didn't already owe you a beer, I do so
doubly now.

------
rcirka
I've used AFNetworking pre-iOS7 and it's been a godsend. However with the
advent on NSURLSession, I don't see the need to have a 3rd party wrapper to do
network calls anymore. Although I admire Mattts' efforts, I'm still not
convinced using AFNetworking 2.0 is more effective than using NSURLSession
directly.

~~~
matttthompson
In my opinion, no better case for AFNetworking 2.0 wrt/NSURLSession can be
made than AFURLSessionManager, and all of the great stuff it does for you.
[http://cocoadocs.org/docsets/AFNetworking/2.0.0/Classes/AFUR...](http://cocoadocs.org/docsets/AFNetworking/2.0.0/Classes/AFURLSessionManager.html)

Another essential feature is SSL pinning, which helps prevent against man-in-
the-middle attacks and other vulnerabilities. If your app interacts with any
sensitive customer information, you would be well-advised to take a look at
AFSecurityPolicy:
[http://cocoadocs.org/docsets/AFNetworking/2.0.0/Classes/AFSe...](http://cocoadocs.org/docsets/AFNetworking/2.0.0/Classes/AFSecurityPolicy.html)

If you're using UIKit, there's a good chance that at least one of the many
UIKit extensions would be worth your while:
[https://github.com/AFNetworking/AFNetworking/tree/master/UIK...](https://github.com/AFNetworking/AFNetworking/tree/master/UIKit%2BAFNetworking)

I also think serializers will have a dramatic impact on the reusability and
composability of business logic across your application in a really elegant
way.

I'd be very interested to hear your thoughts as you do networking on iOS 7
with and without AFNetworking. Feel free to reach out over Twitter or email.

------
comatose_kid
Very cool. Also, check out and sign up for Matt's link (at the bottom of the
page) for his upcoming OReilly book - AFNetworking the definitive guide.

------
CodeWithCoffee
I've been playing around with it for the part couple of weeks or so since his
original announcement and it is really awesome - if you aren't already using
it, or you're using AFNetworking 1.x in your apps I highly recommend using 2.0
- the serialization and session stuff has made the API not only more
streamlined, but helps create really nice code.

------
laveur
This may be the unpopular opinion, but I would never use this. It adds to much
complexity in my opinion. To many things that can break. Sure it gives you a
lot of stuff that makes things quicker to implement. Plus you have to abide by
their design and now how you think it should work. And frankly that doesn't
sit well with me.

~~~
seivan
Not unpopular at all. I've been considering this precise thought myself. So
far haven't bailed yet, but still looking into it.

Concerns are that once I make my own, I will make the same mistakes, and in
the end it would have been fruitless. AFNetworking is one of those libraries
that is if I were to remake it, I'd make similar mistakes and end up hating
what I made.

~~~
dcaunt
What mistakes do you think AFNetworking has made?

~~~
seivan
Incredibly bloated, massive interface files, too many coupled classes.

------
danielrhodes
There look to be some solid improvements.

Originally I saw that the 2.0 release would only work on iOS 7. Does it work
with iOS 6 and under now as well? That would make me more bullish on
upgrading.

~~~
matttthompson
Yes, AFNetworking 2.0 (with the exception of `NSURLSession` functionality) is
compatible with iOS 6 and Mac OS X 10.8.

(This was changed from the original plan to only target iOS 7, after it was
determined that A) only the two classes needed iOS 7, and B) although iOS 7
adoption is crazy good, the same isn't as true of OS X)

------
neebz
Can anyone compare it to MKNetworkKit
([https://github.com/MugunthKumar/MKNetworkKit/](https://github.com/MugunthKumar/MKNetworkKit/))
?

I have been using it for a few projects and it's been really helpful. Has the
correct level of abstraction.

------
rgbrgb
Has anyone used the real-time rocket stuff?

~~~
laveur
As in RocketSockets' Websocket implementation? I use that all the time at
work.

