README.md

AFNetworking

A delightful iOS networking library with NSOperations and block-based callbacks

There's a lot to be said for a networking library that you can wrap your head around. API design matters, too. Code at its best is poetry, and should be designed to delight (but never surprise).

AFNetworking is lovingly crafted to make best use of our favorite parts of Apple's Foundation framework: NSOperation for managing multiple concurrent requests, NSURLRequest & NSHTTPURLResponse to encapsulate state, NSCache & NSURLCache for performant and compliant cacheing behavior, and blocks to keep request / response handling code in a single logical unit in code.

At its core is AFHTTPRequestOperation, a thin wrapper around NSURLConnection, which provides a block callback for when the operation completes. Everything else is built on top of that in a way that's completely modular: take what you need, leave what you don't.

If you're tired of massive libraries that try to do too much...
If you've taken it upon yourself to roll your own hacky solution...
If you want a library that actually makes iOS networking code kinda fun...

...try out AFNetworking

Documentation

To install the docset directly into your local Xcode organizer, first install appledoc, and then clone this project and run appledoc -p AFNetworking -c "Gowalla" --company-id com.gowalla AFNetworking/*.h

Example Project

In order to demonstrate the power and flexibility of AFNetworking, we've included a small sample project, which asks for your current location and displays Gowalla spots nearby you. It uses AFJSONRequestOperation to load and parse the spots JSON, and a category on UIImageView to asynchronously load spot stamp images as you scroll.

Dependencies

If you're using iOS 5, AFJSONRequestOperation uses JSON will use the built-in NSJSONSerialization class to parse JSON responses. If this is not available, it falls back on JSONKit.

ARC Support

If you are including AFNetworking in a project with Automatic Reference Counting (ARC) enabled, you will need to set the -fno-objc-arc compiler flag on all of the AFNetworking source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. In the "Compiler Flags" column, set -fno-objc-arc for each of the AFNetworking source files.

This is certainly suboptimal, forking the project into an ARC and non-ARC branch would be extremely difficult to maintain. On the bright side, we're very excited about CocoaPods, which is a promising solution to this and many other pain points.

Mac OS X Support

Full support for OS X is planned for the very near future. In the meantime, you are perfectly safe to use AFHTTPRequestOperation, AFJSONRequestOperation, AFHTTPClient, and AFNetworkActivityIndicatorManager.