0

Basically I am accessing this URL

http://maps.googleapis.com/maps/api/geocode/json?address=sudirman&sensor=true&bounds=-7.186696,105.7727|-5.186696,107.7727

However, the result is empty. Even though it should show something. I used objective-c

With this code:

response= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlresponse error:&error];

json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];

I think the | need to be urlencoded. How to do so?

Jamie Taylor
  • 4,709
  • 5
  • 44
  • 66
user4951
  • 32,206
  • 53
  • 172
  • 282
  • Possible duplicate. See [How to encode a URL in JavaScript?](http://stackoverflow.com/questions/332872/how-to-encode-a-url-in-javascript) – Anto Jurković Feb 12 '14 at 12:00

1 Answers1

0
[NSURLConnection sendSynchronousRequest:request returningResponse:&urlresponse error:&error];

returns NSData, which when serialised will produce JSON, so you need to do:

NSDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:&error];

to get the JSON.

Nick
  • 939
  • 1
  • 12
  • 19