Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

AFNetworking FAQ

Aaron Brager edited this page Nov 20, 2013 · 30 revisions

I'm Getting Compiler Errors About dispatch_queue_t Being a strong @property, What's Up With That?

As of iOS 6, dispatch_queue_t and other dispatch types are treated as objects, and as such, the correct @property ownership is strong. If you're getting a warning about this from Xcode, check that your targeted SDK is at least iOS 6 or Mac OS X 10.8, the minimum development targets for AFNetworking.

Does AFNetworking have any caching mechanisms built-in?

AFNetworking takes advantage of the caching functionality already provided by NSURLCache and any of its subclasses. So long as your NSURLRequest objects have the correct cache policy, and your server response contains a valid Cache-Control header, responses will be automatically cached for subsequent requests.

Can I use AFNetworking for OAuth?

Yes. Check out AFOAuth1Client or AFOAuth2Client.

What's the best way to test/mock network requests with AFNetworking?

Use NSURLProtocol to intercept requests before they hit the network, and return canned responses using local data. More information about this technique can be found in this blog post by Claus Broch.

There are also some great third-party libraries, including Nocilla and OHHTTPStubs, which provide block-based interfaces for NSURLProtocol HTTP stubbing and mocking.

How do I generate documentation?

Docsets can be generated from the AFNetworking source code using appledoc. Install appledoc, and in the root AFNetworking project directory, enter the following command:

$ appledoc --project-name="AFNetworking" --project-company="AFNetworking" --company-id="com.afnetworking.afnetworking" AFNetworking/*.h

What's with the "AF" prefix?

The "AF" in AFNetworking stands for "Alamofire", which is the former name of Gowalla. Alamofire Inc. was named after the Alamo Fire, a hybrid of the Bluebonnet--Texas' state flower.

Using AF is also a nod to the "NS" prefix used in Apple's Foundation framework, which harkens back to its NeXTSTEP roots.