I am trying to get data from google distance api using NSURLSession, but as shown below, in the code, when I print the response and data, I get the results as NULL. What could be the problem? or is there another better way to get JSON data.
NSString *urlAsString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR&key=API-KEY"]; NSURL *url = [NSURL URLWithString:urlAsString]; NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; [[session dataTaskWithURL:[NSURL URLWithString:urlAsString] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSLog(@"RESPONSE: %@",response); NSLog(@"DATA: %@",data); }] resume];
json ios objective-c iphone nsurlsession
Mukul more
source share