Changeset 13357


Ignore:
Timestamp:
Jun 28, 2012, 12:29:01 PM (9 years ago)
Author:
livings124
Message:

only create the number formatter for formatting integers once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/NSStringAdditions.m

    r13251 r13357  
    4949}
    5050
     51#warning use localizedStringWithFormat: directly in roardacted
    5152+ (NSString *) formattedUInteger: (NSUInteger) value
    5253{
    53     NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
    54     [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
    55     [numberFormatter setMaximumFractionDigits: 0];
     54    static NSNumberFormatter * numberFormatter;
     55    static dispatch_once_t onceToken;
     56    dispatch_once(&onceToken, ^{
     57        numberFormatter = [[NSNumberFormatter alloc] init];
     58        [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
     59        [numberFormatter setMaximumFractionDigits: 0];
     60    });
    5661   
    5762    return [numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: value]];
Note: See TracChangeset for help on using the changeset viewer.