字符串文字而不必转义特殊字符? [英] String literals without having to escape special characters?

查看:229
本文介绍了字符串文字而不必转义特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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:...).

这篇关于字符串文字而不必转义特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆