Using 'stringWithString:' with a literal is redundant
This question already has an answer here:
Obj-C: [NSString stringWithString:@“string”] vs. @“string”
- Handling Game Center authentication
- In Xcode 6 Beta 4 stroking with SKShapeNode doesn't work anymore
- populating a tableview with data using JSON and AFNetworking NSDictionary
- Get file size in Swift
- How to test a iPhone app on my device with developer team member?
- presentViewController from TableViewCell
4 Solutions Collect From Internet About “Using 'stringWithString:' with a literal is redundant”
The warning is saying that you could instead easily do like this:
statusString = @"Not Reachable";
The explanation is provided in the post
Obj-C: [NSString stringWithString:@"string"] vs. @"string"
Instead of using
statusString = [NSString stringWithString: @"Not Reachable"];
please write your code like below:
statusString = @"Content-Type: Not Reachable/unknown\r\n\r\n";
warning will be removed.
You resolve these ‘warnings’ simply by declaring your strings like so:
statusString = @"";
statusString = [NSString stringWithString:@""];
I think this is a type of compiler optimization. Actually you need to assign a string to variable. You can do it directly as
myString = @"" no need to call a method and it will use additional processing time.
- Instantiating split view controller by identifier in OS X storyboard does not load view hierarchy
- UIBezierPath in NSDictionary – is it possible?
- Creating UIActionSheet
- What is proper way to get ETA (estimated time arrival) from any location to my current location
- Disable Horizontal Scrolling to UITextView Programmatically
- Is PNG preferred over JPEG for all image files on iOS?
- UIDatePicker restrict hours but not date
- Switching avaudiosession categories then retaking control of remote control center controls
- Using multiple let-as within a if-statement in Swift
- Cannot get my location to show up in Google Maps in iOS 8
- UIDocumentInteractionController adding custom actions to menu (eg email, save to photos)
- iOS – How to programmatically connect to a WiFi network given the SSID and Password using a private/3rd party library
- OpenGL ES 1 multi-texturing with different uv coordinates
- iOS NSDate() returns incorrect time
- Why does iOS auto layout lead to apparent rounding errors on pre-Retina displays (unit test included)