objective-c - 像 Objective-C 中的 Python 那样的原始字符串

标签 objective-c string

Objective-C有没有raw strings like Python's

说明:原始字符串不会像 \n 那样解释转义序列:斜线和“n”都是字符串中的独立字符。来自链接的 Python 教程:

>>> print 'C:\some\name'  # here \n means newline!
C:\some
ame
>>> print r'C:\some\name'  # note the r before the quote
C:\some\name

最佳答案

Objective-C 是 C 的超集。所以,答案是肯定的。你可以写

char* string="hello world";

任何地方。然后你可以通过

把它变成一个 NSString
NSString* nsstring=[NSString stringWithUTF8String:string];

关于objective-c - 像 Objective-C 中的 Python 那样的原始字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2151903/

相关文章:

c++ - 如何检查字符串是否是另一个字符串的真子集

python - Python 中的多重拆分

ios - 在 iOS 中保持登录到 Google OAuth 2.0 服务

iphone - 连接信用卡读卡器

Java - 什么数据结构为预加载字符串数组和检查字符串是否存在提供最快的性能?

python - 如何从字典中创建一个句子

ios - UICollectionView header view like table view header

iphone - 更改当前 iphone 应用程序的区域设置(NSBundle 的自定义区域设置?)

c++ - 从 Objective-C++ 调用 C++ 时出现 BAD_ACCESS 错误。所有文件都是 .mm 但仍然是这个问题

java - 字符串和字节数组中 BigInteger 值的差异