With ARC, what's better: alloc or autorelease initializers?

Viewed 7706

Is it better (faster & more efficient) to use alloc or autorelease initializers. E.g.:

- (NSString *)hello:(NSString *)name {
    return [[NSString alloc] initWithFormat:@"Hello, %@", name];
}

OR

- (NSString *)hello:(NSString *)name {
    return [NSString stringWithFormat:@"Hello, %@", name];
//    return [@"Hello, " stringByAppendingString:name]; // even simpler
}

I know that in most cases, performance here shouldn't matter. But, I'd still like to get in the habit of doing it the better way.

If they do exactly the same thing, then I prefer the latter option because it's shorter to type and more readable.

In Xcode 4.2, is there a way to see what ARC compiles to, i.e., where it puts retain, release, autorelease, etc? This feature would be very useful while switching over to ARC. I know you shouldn't have to think about this stuff, but it'd help me figure out the answer to questions like these.

6 Answers
Related