在Objective-c中是否有字符串文字形式,不需要转义特殊字符?换句话说,我正在寻找一个相当于Python的三重报价。
Is there a string literal form in Objective-c that does not require escaping special characters? In other words, I'm looking for an equivalent to the Python triple quote.
我试图把一些HTML放入一个 NSString ,并且希望避免从所有HTML属性中转义引号。
I'm trying to put some HTML into an NSString, and would like to avoid having to escape the quotes from all the HTML attributes.
推荐答案没有相当于三重报价;字符串文字必须始终使用特殊字符的转义。
There's no equivalent to the triple-quote; string literals must always use escapes for special characters.
也许最好的做法是将HTML放入与源文件分开的文件中,然后使用rel =nofollow> - [NSString initWithContentsOfFile:encoding:error:] (或相关的 initWithContentsOfURL:... )。
Perhaps the best thing to do would be to put your HTML into a file separate from your source, then create the string using -[NSString initWithContentsOfFile:encoding:error:] (or the related initWithContentsOfURL:...).
更多推荐
字符串文字而不必转义特殊字符?
发布评论