Skip to content

Instantly share code, notes, and snippets.

@mluton
Created September 11, 2015 18:25
Show Gist options
  • Save mluton/b0483e09b3cb48e3f54e to your computer and use it in GitHub Desktop.
Save mluton/b0483e09b3cb48e3f54e to your computer and use it in GitHub Desktop.
Simple JSON URL Request
NSURLSession *session = [NSURLSession sharedSession];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.example.com/endpoint_%@.json", parameter]];
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
}];
[dataTask resume];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment