tags:

views:

35

answers:

1

Hi,

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 *urlString = [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

+3  A: 

Put another \ in front of it to escape it:

http://DOMAIN\\Username
Ben
Simple as that. The backslash is used as a special input character in many languages, e.g `\n` means new line.
Emil
I have already tried this. And URL becomes nil. Kindly suggest
Yasar