I was just curious, is there any difference between the following two codes?
NSString *aString = [NSString stringWithString:@”a string”];
NSString *aString = @”a string”;
I wonder what exactly is going on when you do the latter way.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both point to a literal string created at compile time.
Even though stringWithString suggest it’s autoreleased, a literal string will never get released.
See my related post here:
Difference between NSString literals
From the apple docs @ https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/CreatingStrings.html