Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An implementation of NSURLConnection's sendAsynchronousRequest: for iOS 4
Objective-C
tree: 7e733e6383

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
AEURLConnection
Example
LICENSE
README.md

README.md

AEURLConnection

Effortless, safe block-based URL requests

iOS 5 introduces sendAsynchronousRequest:queue:completionHandler:, a great new API that makes it easy to dispatch a NSURLRequest and safely receive a callback when it finishes.

AEURLConnection is a simple reimplementation of the API for use on iOS 4. Used properly, it is also guaranteed to be safe against The Deallocation Problem, a thorny threading issue that affects most other networking libraries.

How do I use it?

  1. Construct an NSURLRequest.
  2. Send it like this:

    [AEURLConnection sendAsynchronousRequest:request 
                                       queue:[NSOperationQueue mainQueue] 
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
        // Handle the response, or error.
    }];
    
  3. That's all there is!

What's this "Deallocation Problem"?

explanation to come.

Don't I want to use an NSOperation?

Almost certainly not.

Most other Cocoa networking libraries (like ASIHTTPRequest and AFNetworking) have seized on the idea of using NSOperation to encapsulate a network operation. This is appealing; fetching something from a network is operation-like, so why not use NSOperation?

Something went wrong with that request. Please try again.