From c72a2cb1490151aaa3cfca4923175ab75e8a1f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <felix@feepk.net> Date: Mon, 3 Jun 2019 11:27:10 +0200 Subject: [PATCH] macosx: remove VLCByteCountFormatter Targetted macOS versions include NSByteFormatter which should be used instead. --- modules/gui/macosx/extensions/misc.h | 8 ---- modules/gui/macosx/extensions/misc.m | 68 ---------------------------- 2 files changed, 76 deletions(-) diff --git a/modules/gui/macosx/extensions/misc.h b/modules/gui/macosx/extensions/misc.h index 0317ae718e82..75b34744649b 100644 --- a/modules/gui/macosx/extensions/misc.h +++ b/modules/gui/macosx/extensions/misc.h @@ -41,11 +41,3 @@ errorDescription:(NSString**)error; @end - -/***************************************************************************** - * VLCByteCountFormatter addition - *****************************************************************************/ - -@interface VLCByteCountFormatter : NSFormatter -+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle; -@end diff --git a/modules/gui/macosx/extensions/misc.m b/modules/gui/macosx/extensions/misc.m index d81d758c56f7..2f46b73e145c 100644 --- a/modules/gui/macosx/extensions/misc.m +++ b/modules/gui/macosx/extensions/misc.m @@ -68,71 +68,3 @@ } @end - -/***************************************************************************** - * VLCByteCountFormatter addition - *****************************************************************************/ - -@implementation VLCByteCountFormatter - -+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle -{ - // Use native implementation on >= mountain lion - Class byteFormatterClass = NSClassFromString(@"NSByteCountFormatter"); - if (byteFormatterClass && [byteFormatterClass respondsToSelector:@selector(stringFromByteCount:countStyle:)]) { - return [byteFormatterClass stringFromByteCount:byteCount countStyle:NSByteCountFormatterCountStyleFile]; - } - - float devider = 0.; - float returnValue = 0.; - NSString *suffix; - - NSNumberFormatter *theFormatter = [[NSNumberFormatter alloc] init]; - [theFormatter setLocale:[NSLocale currentLocale]]; - [theFormatter setAllowsFloats:YES]; - - NSString *returnString = @""; - - if (countStyle != NSByteCountFormatterCountStyleDecimal) - devider = 1024.; - else - devider = 1000.; - - if (byteCount < 1000) { - returnValue = byteCount; - suffix = _NS("B"); - [theFormatter setMaximumFractionDigits:0]; - goto end; - } - - if (byteCount < 1000000) { - returnValue = byteCount / devider; - suffix = _NS("KB"); - [theFormatter setMaximumFractionDigits:0]; - goto end; - } - - if (byteCount < 1000000000) { - returnValue = byteCount / devider / devider; - suffix = _NS("MB"); - [theFormatter setMaximumFractionDigits:1]; - goto end; - } - - [theFormatter setMaximumFractionDigits:2]; - if (byteCount < 1000000000000) { - returnValue = byteCount / devider / devider / devider; - suffix = _NS("GB"); - goto end; - } - - returnValue = byteCount / devider / devider / devider / devider; - suffix = _NS("TB"); - -end: - returnString = [NSString stringWithFormat:@"%@ %@", [theFormatter stringFromNumber:[NSNumber numberWithFloat:returnValue]], suffix]; - - return returnString; -} - -@end -- GitLab