避免在文字字符串中使用转义字符

时间:2022-05-17 00:43:21

Is there a way I can avoid escape sequences in literal strings in Objective-C?

有没有办法可以避免Objective-C中文字字符串中的转义序列?

For example, in C#, I can prefix the string with @ and type the string normally, like: @"C:\Users", without the use of the double backslash "C:\\Users"

例如,在C#中,我可以在字符串前加上@并正常输入字符串,如:@“C:\ Users”,而不使用双反斜杠“C:\\ Users”

Is there a way to do this?

有没有办法做到这一点?

1 个解决方案

#1


1  

There is no way to do this in Objective-C. A construction like @"string" generates an NSString object built from the plain "string". And as far as I know, you cannot avoid escaping in the C language.

在Objective-C中无法做到这一点。像@“string”这样的结构生成一个由普通“string”构建的NSString对象。据我所知,你无法避免在C语言中逃避。

#1


1  

There is no way to do this in Objective-C. A construction like @"string" generates an NSString object built from the plain "string". And as far as I know, you cannot avoid escaping in the C language.

在Objective-C中无法做到这一点。像@“string”这样的结构生成一个由普通“string”构建的NSString对象。据我所知,你无法避免在C语言中逃避。