Joris Kluivers

I like to build software.

My New Favourite: Easy Async NSURLConnection

Single line URL connections! I actually made my own category on NSURLConnection before, to do a similar thing. I’m happy this is now obsolete and I can use the iOS5/OSX10.7 built-in.

1
-[NSURLConnection sendAsynchronousRequest:queue:completionHandler];

Example:

1
2
3
4
5
6
[NSURLConnection
    sendAsynchronousRequest:request
    queue:self.queue
    completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
    // do something useful
}];