I am wondering what differences such as disadvantages and/or advantages there are to declaring an NSString this way:
NSString *noInit = [NSString stringWithFormat:@"lolcatz %d", i];
as opposed to:
NSString *withInit = [[NSString alloc] initWithFormat:@"Hai %d", i];
What was the motivation of putting stringWithFormat instead of just having the initWithFormat way of initializing the string?
stringWithFormat:returns an autoreleased string;initWithFormat:returns a string that must be released by the caller. The former is a so-called “convenience” method that is useful for short-lived strings, so the caller doesn’t have to remember to callrelease.