PDA

View Full Version : Escaping a double quote.




dusker
Jul 22, 2009, 03:51 PM
Hi,
this is probably very simple, but i've been googling this with no result.
I need to have a string with several double quotes in it. How do you escape double quote in objective-c? (since obviously @"It is called "monument""; doesnt work :)

thanks
peter



sergio27
Jul 22, 2009, 04:06 PM
Hi, dusker. I'm almost positive that you just need to put an inverted slash ('\') before the double quote for it to work. I'm not in my Mac right now so I can't confirm it.

NSString *sample = @"It is called \"monument\"";

dusker
Jul 22, 2009, 04:36 PM
Hi Sergio
this worked, thanks so much!
greetings
peter

peacetrain67
Jul 22, 2009, 05:13 PM
Hi,
this is probably very simple, but i've been googling this with no result.
I need to have a string with several double quotes in it. How do you escape double quote in objective-c? (since obviously @"It is called "monument""; doesnt work :)

thanks
peter

Use backslash. Example: NSLog(@"Calling \"This View\" Now")