What is the difference between these two ways of creating NSStrings?
Posted
by adame
on Stack Overflow
See other posts from Stack Overflow
or by adame
Published on 2010-06-16T10:36:49Z
Indexed on
2010/06/16
11:22 UTC
Read the original article
Hit count: 152
NSString *myString = @"Hello";
NSString *myString = [NSString stringWithString:@"Hello"];
I understand that using method (1) creates a pointer to a string literal that is defined as static memory (and cannot be deallocated) and that using (2) creates an NSString object that will be autoreleased.
- Is using method (1) bad?
- What are the major differences?
- Is there any instances where you would want to use (1)?
- Is there a performance difference?
P.S. I have searched extensively on Stack Overflow and while there are questions on the same topic, none of them have answers to the questions I have posted above.
© Stack Overflow or respective owner