I have a label that displays inches. I would like to display the number with the inch symbol (") or quotation mark. Can I do this with an nsstring? Thanks!
+1
A:
Yes, you can include a quotation mark in an NSString
literal using the backslash to escape it.
For example, to put the string Quote " Quote
in a string literal, you would use this:
@"Quote \" Quote"
A backslash followed by a quotation mark simply inserts the quotation mark into the string.
John Calsbeek
2009-12-20 04:57:44
+7
A:
Sure, you just need to escape the quotation mark.
NSString *someString = @"This is a quotation mark: \"";
NSLog(@"%@", someString );
Output:
This is a quotation mark: "
Jeff Kelley
2009-12-20 04:59:11
Awesome! That's what I was looking for!
Jonah
2009-12-20 05:09:37
Wow thanks so much
Jaba
2009-12-20 05:36:36
Amazing people are writing iPhone apps, and they don't know basic C-style string encoding... how on earth are they going to manage memory effectively?
Mike Weller
2009-12-20 07:15:29
Everybody has to start someone. Besides, everyone forgets trivial things from time to time. The other day, I couldn't remember the string formatter for hex and I've been programming in C for mumble-mumble years.
TechZen
2009-12-20 15:06:59
+1
A:
If the string is a literal string, then you can use the escape character to add a quotation mark inside a string.
NSString *string = @"16\"";
kiamlaluno
2009-12-20 05:00:50