Question

I got the following warning

Using 'stringWithString': with a literal is redundant

while using the method usingWithString

[NSString stringWithString:@"Content-Type: content/unknown\r\n\r\n"]
Was it helpful?

Solution

I solved the issue by replacing [NSString stringWithString:@"Content-Type: content/unknown\r\n\r\n"] to @"Content-Type: content/unknown\r\n\r\n"

OTHER TIPS

The warning is because of you would better use @"" to init a string.For example:

 NSString *s1 = @"s1";
 NSString *s3 = [[NSString alloc] initWithString:@"s1"];

we can print their address:

2017-02-08 11:38:46.997201 Test[7484:2245410] s1:0x10009c088 s1
2017-02-08 11:38:46.997290 Test[7484:2245410] s3:0x10009c088 s1

we can find that they point a same address.So apple recommand to use " @"" " reather than "initWithString".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top