Abdul Ahmad
Abdul Ahmad

Reputation: 10021

maintain forward slash in ios string

I'm trying to do the following in xcode:

NSString *URL = @"http://someUrl/page.php";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:URL]];

but I'm not sure if the forward slashes are maintained when they are in double quotes. I don't know what the rules are for ios characters in single/double quotes.

does the URL String remain exactly as was declared in the quotes? thanks

Upvotes: 2

Views: 3126

Answers (2)

Tiago Lira
Tiago Lira

Reputation: 2550

You can do that, I've used that often without any problems. If you wanted the backslash (\), then you would have to escape it.

Upvotes: 5

kljhanson
kljhanson

Reputation: 136

The string in your example will be exactly as you declared it. For reference, \ is the escape character for strings in objective-c. If you want to use a backslash, you would then have to double it (e.g., \\).

Upvotes: 3

Related Questions