Created
February 1, 2020 23:47
-
-
Save ncooke3/b11ce58110d02c2320771a27d61f007b to your computer and use it in GitHub Desktop.
Simple Objective-C API Call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)fetchData { | |
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; | |
[request setHTTPMethod:@"GET"]; | |
[request setURL:[NSURL URLWithString:stringURL]]; | |
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, | |
NSURLResponse * _Nullable response, | |
NSError * _Nullable error) { | |
NSString *myString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | |
NSLog(@"Data received: %@", myString); | |
}] resume]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment