Lately, I have been using Automatic Reference Counting in my Objective-C/iOS programs, and have really been enjoying the feature.
One thing I don't understand about it is the proper method to initialize an NSString
. I have seen this method used with both ARC and non-ARC projects:
NSString *myClassicString = [[NSString alloc] initWithFormat:@"My great non-ARC string!"];
I have also found that the following method can be used for initializing an NSString
in ARC, and I prefer it because of the convenience:
NSString *myARCString = [NSString stringWithFormat:@"My new simple initialization string!"];
Is there any difference between these two? Is there a proper way? Is either one better?