0

I'm able to form URL to access Google direction webservice. But when I use optimize factor or when I use "optimize:true|", I get nil in URL. It may be because I am using "|" sign in URL.

How I can fix this?

NSString *URLAddress=[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/xml?origin=%@&destination=%@&waypoints=optimize:true|%@&sensor=false",updated_Address_Of_Source,updated_Address_Of_Destination,updated_Address_Of_Waypoint]; NSURL *URL=[NSURL URLWithString:URLAddress];

Olli
  • 1,231
  • 15
  • 31
Varun Mehta
  • 1,733
  • 3
  • 18
  • 39

1 Answers1

1

Yes, if you use special characters such as '|' in a URL you must escape them. There's quite a few guides out there on this, but see this stack overflow question: Objective C HTML escape/unescape

See also http://www.blooberry.com/indexdot/html/topics/urlencoding.htm.

Community
  • 1
  • 1
occulus
  • 16,959
  • 6
  • 53
  • 76
  • That's not how you escape URLs. Go and read some documentation! The link I posted just above would be a good start. – occulus Feb 22 '11 at 14:25
  • But in case you're incredibly impatient, the way to encode a pipe in a URL is to use the three characters %7C. Read the docs! – occulus Feb 22 '11 at 14:27
  • Also, the pipe isn't the only character in your URL that needs escaping. Check out my second link above for more info about special chars. – occulus Feb 22 '11 at 14:36
  • If you found my answer at all useful, please consider accepting it (by clicking the 'tick' at left). This benefits us both! – occulus Feb 24 '11 at 09:21