如何使用双引号将NSString初始化为文本[duplicate]

时间:2022-09-15 15:23:18

This question already has an answer here:

这个问题在这里已有答案:

i want to initialize NSString is as "hai" with double qoutes..is it possible? any help please? but NSString *str = @"hai"; i want to convert it as "hai" without direct initialization?any help pls?

我想初始化NSString是双haoutes的“hai”..它可能吗?有什么帮助吗?但是NSString * str = @“hai”;我想将它转换为“hai”而无需直接初始化?有什么帮助吗?

2 个解决方案

#1


6  

If you want to convert an existing string please use this:

如果要转换现有字符串,请使用:

NSString *newString = [NSString stringWithFormat:@"\"%@\"",str];

#2


2  

NSString* foo = @"\"hai\"";

NSString * foo = @“\”hai \“”;

#1


6  

If you want to convert an existing string please use this:

如果要转换现有字符串,请使用:

NSString *newString = [NSString stringWithFormat:@"\"%@\"",str];

#2


2  

NSString* foo = @"\"hai\"";

NSString * foo = @“\”hai \“”;