I think the question is clear enough but still – what’s the difference between:
NSString *string = @"Hello world!";
and
NSString *string = [[NSString alloc] initWithString:@"Hello world!"];
Let me know if this already answers it.
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.
Per cocoa as cocoa naming convention, You create an object using a method whose name begins with “alloc”, “new”, “copy”, or “mutableCopy”. That means you own the string above, hence you’re responsible to release the object.
The line above is a string literal / constant, you don’t alloc it or release it. You don’t own this object.