views:

73

answers:

1

Hi all, I am trying to access google maps' forward geocoding service from my iphone app. When i try to make an NSURL from a string with a pipe in it I just get a nil pointer.

NSURL *searchURL = [NSURL URLWithString:@"http://maps.google.com/maps/api/geocode/json?address=6th+and+pine&bounds=37.331689,-122.030731|37.331689,-122.030731&sensor=false"];

I dont see any other way in the google api to send bounds coordinates with out a pipe. Any ideas about how I can do this?

+5  A: 

Have you tried replacing the pipe with %7C (the URL encoded value for the char |)?

Ben S
yes that worked. ha thank you, I am a complete url noob.
aks
Doesn't NSString have a – stringByAddingPercentEscapesUsingEncoding: method that does that for you?
Tom H
doh. that is exactly what i needed, just didnt know about percent escapes besides %20. Thanks guys
aks