4

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"]
Jun
  • 3,422
  • 3
  • 28
  • 58

2 Answers2

9

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"

Jun
  • 3,422
  • 3
  • 28
  • 58
0

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".

Scott
  • 162
  • 1
  • 12