I'd like double quotes to appear within the following string so it looks like:
我想在下面的字符串中出现双引号,所以它看起来像:
"hi there == "
Here's the code I'm using:
这是我正在使用的代码:
NSMutableString *s = [[NSMutableString alloc] init];
[s appendString:@""""];
[s appendString:@"hi there == ""\n\r"];
Instead I only get:
相反,我只得到:
hi there ==
Any ideas?
有任何想法吗?
3 个解决方案
#1
46
[s appendString:@"hi there == \"\n\r"];
\"
is what is needed for "
- This is standard C formatting.
“是所需要的” - 这是标准的C格式。
#2
0
Although Its late but we can Try this:
虽然很晚但我们可以试试这个:
[NSString stringWithFormat:@"\"Hi There=\" Other text"];
#3
-2
You have to append a slash (\) before the quote (") to ge the expected output.
您必须在引号(“)之前附加斜杠(\)以获得预期输出。
[s appendString:@"\"hi there == \"\n\r"];
Output will be "hi there == "
输出将是“hi there ==”
#1
46
[s appendString:@"hi there == \"\n\r"];
\"
is what is needed for "
- This is standard C formatting.
“是所需要的” - 这是标准的C格式。
#2
0
Although Its late but we can Try this:
虽然很晚但我们可以试试这个:
[NSString stringWithFormat:@"\"Hi There=\" Other text"];
#3
-2
You have to append a slash (\) before the quote (") to ge the expected output.
您必须在引号(“)之前附加斜杠(\)以获得预期输出。
[s appendString:@"\"hi there == \"\n\r"];
Output will be "hi there == "
输出将是“hi there ==”