我见过人们做的事情[NSString stringWithString:@"some string"].为什么不@"some string"呢?
举个例子,看看facebook-ios-sdk.
+ [NSString stringWithString:] - 重点是什么?是一个类似的问题,但没有一个答案解决[NSString stringWithString:@"some string"]与@"some string".
我对此很新 - 我正在尝试将NSString stringWithFormat与一些文本进行比较.它与stringWithString一起工作正常.我无法弄清楚为什么它不能与stringWithFormat一起使用?非常感谢任何人提供的任何帮助!
NSString *theQuestion = [NSString stringWithFormat:@"The same thing"];
if (theQuestion == @"The same thing"){
NSLog(@"stringWithFormat is the same as the given text");
}else{
NSLog(@"stringWithFormat is NOT the same as the given text");
NSLog(@"but theQuestion is:\"%@\"", theQuestion);
}
Run Code Online (Sandbox Code Playgroud) 我收到了以下警告
Using 'stringWithString': with a literal is redundant
在使用该方法时 usingWithString
[NSString stringWithString:@"Content-Type: content/unknown\r\n\r\n"]
Run Code Online (Sandbox Code Playgroud)