Obj-C:[NSString stringWithString:@" string"] vs. @“string”
我看过人们做了 [NSString stringWithString:@some string]
。为什么不只是 @一些字符串
?
I've seen people do something like [NSString stringWithString:@"some string"]
. Why not just do @"some string"
?
例如,查看facebook-ios-sdk
。
For an example, look at the facebook-ios-sdk
.
NSString stringWithString - 什么是point?是一个类似的问题,但没有答案地址 [NSString stringWithString:@some string]
vs. @一些字符串
。
NSString stringWithString - what's the point? is a similar question, but none of the answers address [NSString stringWithString:@"some string"]
vs. @"some string"
.
实际上没有区别。 [NSString stringWithString:str]
不执行任何操作,并返回 str
if str
已不可变。
Actually there is no difference. [NSString stringWithString: str]
just does nothing and returns str
if str
is immutable already.