stringWithFormat: is a class method of NSString, and returns an autoreleased string; initWithFormat: is an instance method, and before ARC the programmer had to take care of the returned object’s memory management. If we have ARC turned on, what is the difference between the two methods?
stringWithFormat: is a class method of NSString , and returns an autoreleased string; initWithFormat:
Share
With
ARCenabled, these two methods are equivalent (i.e.ARCwill auto-callautoreleasemethod; always registering to nearest@autoreleasepool).See:
Counting
In-Depth (explains how ARC code compiles)