Skip to content

Instantly share code, notes, and snippets.

@DonMag
Last active March 30, 2016 19:58
Show Gist options
  • Select an option

  • Save DonMag/276067ad23f7542c11ff981446bde2c5 to your computer and use it in GitHub Desktop.

Select an option

Save DonMag/276067ad23f7542c11ff981446bde2c5 to your computer and use it in GitHub Desktop.
- (IBAction)runTestURL:(id)sender {
// 1
NSString *dataUrl = @"https://someurl.com";
NSURL *url = [NSURL URLWithString:dataUrl];
// 2
NSURLSessionDataTask *downloadTask = [[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
// 4: Handle response here
NSString *s = = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}];
// 3
[downloadTask resume];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment