Skip to content

Instantly share code, notes, and snippets.

@nicklockwood
Created February 9, 2013 08:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicklockwood/4744639 to your computer and use it in GitHub Desktop.
Save nicklockwood/4744639 to your computer and use it in GitHub Desktop.
Async networking on iOS
NSURLrequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/file.json"]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment