[vlc-commits] macosx: check for NSByteCountFormatter on runtime, to fix compilation on snow leopard

David Fuhrmann git at videolan.org
Fri Feb 28 14:06:51 CET 2014


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Fri Feb 28 13:56:26 2014 +0100| [197604633b252a578d358fb3f604f25b3ef0347b] | committer: David Fuhrmann

macosx: check for NSByteCountFormatter on runtime, to fix compilation on snow leopard

Defining the category to a nonexisting class is not allowed, as well as providing
an interface for this class without implementation.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=197604633b252a578d358fb3f604f25b3ef0347b
---

 modules/gui/macosx/misc.m |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index 6b32540..9873495 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -953,19 +953,15 @@ void _drawFrameInRect(NSRect frameRect)
  * VLCByteCountFormatter addition
  *****************************************************************************/
 
-#ifndef MAC_OS_X_VERSION_10_8
- at interface NSByteCountFormatter (IntroducedInMountainLion)
-+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle;
- at end
-#endif
-
-
 @implementation VLCByteCountFormatter
 
 + (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle
 {
-    if (OSX_MAVERICKS || OSX_MOUNTAIN_LION)
-        return [NSByteCountFormatter stringFromByteCount:byteCount countStyle:NSByteCountFormatterCountStyleFile];
+    // 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.;



More information about the vlc-commits mailing list