Use NSNumberFormatter class method

Once we drop 10.7 support we can avoid NSNumberFormatter entirely by using ‘localizedStringWithFormat:’ with ‘%lu’.
This commit is contained in:
Allan Odgaard
2013-04-17 11:11:51 +07:00
parent 0e290fd599
commit 49235210ca
2 changed files with 3 additions and 15 deletions

View File

@@ -415,13 +415,9 @@ NSString* const FFFindWasTriggeredByEnter = @"FFFindWasTriggeredByEnter";
default: fmt = MSG_MULTIPLE_MATCHES_FMT; break;
}
NSNumberFormatter* formatter = [NSNumberFormatter new]; // FIXME we want to cache this as it is expensive
[formatter setPositiveFormat:@"#,##0"];
[formatter setLocalizesFormat:YES];
NSString* msg = [NSString localizedStringWithFormat:fmt, [_documentSearch searchString], [formatter stringFromNumber:@(totalMatches)]];
NSString* msg = [NSString stringWithFormat:fmt, [_documentSearch searchString], [NSNumberFormatter localizedStringFromNumber:@(totalMatches) numberStyle:NSNumberFormatterDecimalStyle]];
if(!_documentSearch.documentIdentifier)
msg = [msg stringByAppendingFormat:([_documentSearch scannedFileCount] == 1 ? MSG_SEARCHED_FILES_ONE : MSG_SEARCHED_FILES_MULTIPLE), [formatter stringFromNumber:@([_documentSearch scannedFileCount])], [_documentSearch searchDuration]];
msg = [msg stringByAppendingFormat:([_documentSearch scannedFileCount] == 1 ? MSG_SEARCHED_FILES_ONE : MSG_SEARCHED_FILES_MULTIPLE), [NSNumberFormatter localizedStringFromNumber:@([_documentSearch scannedFileCount]) numberStyle:NSNumberFormatterDecimalStyle], [_documentSearch searchDuration]];
self.windowController.statusString = msg;
}

View File

@@ -631,15 +631,7 @@ inline void rank_record (document_record_t& record, filter_string_t const& filte
[self updateStatusText:self];
NSNumberFormatter* formatter = [NSNumberFormatter new];
[formatter setPositiveFormat:@"#,##0"];
[formatter setLocalizesFormat:YES];
NSString* count = [formatter stringFromNumber:@(_items.count)];
if(_items.count == 1)
count = [count stringByAppendingString:@" item"];
else count = [count stringByAppendingString:@" items"];
_itemCountTextField.stringValue = count;
_itemCountTextField.stringValue = [NSString stringWithFormat:@"%@ item%s", [NSNumberFormatter localizedStringFromNumber:@(_items.count) numberStyle:NSNumberFormatterDecimalStyle], _items.count == 1 ? "" : "s"];
}
- (void)updateSCMStatus