How do I include a quote character in a string?
-
26-09-2019 - |
Question
I have to make a web request but its format creates problem for me.
I require www.abc.com?userID="YourUserID"
I am creating following ...
NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.abc.com?userID=%@",myID]];
... which will create a url with string www.abc.com?userID=12345
.
But I require www.abc.com?userID="12345"
I tried to put following:
NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.abc.com?userID="%@"",myID]];
Solution
[NSURL URLWithString:
[NSString stringWithFormat:@"http://www.abc.com?userID=\"%@\"", myID]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow