I am trying to call a web service on iPhone as follows;
NSURL *url = [NSURL URLWithString:@"http://DOMAIN\Username:Password@IPAddress/ServiceName"];
When this line is executed url is nil. But when i remove "\" from above call, url contains the value.
I have already tried using "\\" but it didn't worked. Here is my code
NSString *Domain = [NSString stringWithFormat:@"DOMAIN"];
NSString *name = [NSString stringWithFormat:@"UserName"];
NSString *urlS开发者_开发技巧tring = [NSString stringWithFormat:@"http://%@\\%@:password@IPAddress",Domain,name];
//Above lines executes properly and contains the following
"https://DOMAIN\UserName:password@IPAddress"
But when the following line gets executed url is nil
NSURL *url = [NSURL URLWithString:urlString];
Can any body help me how i can put "\" in URL?
Thanks. Yasar
Put another \ in front of it to escape it:
http://DOMAIN\\Username
Use an UTF8 encoding for the String.
NSURL * url = [NSURL URLWithString:[stringURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
精彩评论