I have to initialize string as "Rose" including Quotation Mark. How to write " in our string?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Escape the double quote with \
NSString *yourString = @"\"Rose\"";
回答2:
Use the escape character: \
NSString *r = @"\"Rose\"";
You can find additional information about Escape character and String literal.
回答3:
Escape it with a backslash:
@"\"Rose\""
回答4:
Escape the quotation marks.
Example:
NSString *str = @"\"Rose\"";
回答5:
NSString *yourString = @"\"Rose\"";
回答6:
In swift 5, you can write with a hashtag :
let raw = #"You can create "raw" strings in Swift 5."#
Output :
You can create "raw" strings in Swift 5.