NSDateFormatter
includes the following convenience method:
+ (NSString *)localizedStringFromDate:(NSDate *)date dateStyle:(NSDateFormatterStyle)dateStyle timeStyle:(NSDateFormatterStyle)timeStyle
The documentation states that using this method is the same as explicitly doing this:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[formatter setDateStyle:dateStyle];
[formatter setTimeStyle:timeStyle];
NSString *result = [formatter stringForObjectValue:date];
Now, I have read in various places that initialising an NSDateFormatter
object has quite an overhead. Does anyone know if the localizedStringFromDate:etc
class method has the same overhead i.e. it causes the instantiation of a new NSDateFormatter
object under the covers every time it is called?