AFNetworking

AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of NSURLConnection, NSOperation, and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL:

Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.

Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!

A subclass of AFURLConnectionOperation for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.

Requirements

ARC

AFNetworking uses ARC as of its 1.0 release.

If you are using AFNetworking 1.0 in your non-arc project, you will need to set a -fobjc-arc compiler flag on all of the AFNetworking source files. Conversely, if you are adding a pre-1.0 version of AFNetworking, you will need to set a -fno-objc-arc compiler flag.

To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all AFNetworking source files, press Enter, insert -fobjc-arc or -fno-objc-arc and then "Done" to enable or disable ARC for AFNetworking.

Unit Tests

AFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via CocoaPods. To do so:

$ gem install cocoapods # If necessary
$ cd Tests
$ pod install

Once CocoaPods has finished the installation, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode.

Test Logging

By default, the unit tests do not emit any output during execution. For debugging purposes, it can be useful to enable logging of the requests and responses. Logging support is provided by the AFHTTPRequestOperationLogger extension, which is installed via CocoaPods into the test targets. To enable logging, edit the test Scheme and add an environment variable named AFTestsLoggingEnabled with a value of YES.

Using xctool

If you wish to execute the tests from the command line or within a continuous integration environment, you will need to install xctool. The recommended installation method is Homebrew.