Commit 19760463 authored by David Fuhrmann's avatar 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.
parent 49f3d107
......@@ -953,19 +953,15 @@ void _drawFrameInRect(NSRect frameRect)
* VLCByteCountFormatter addition
*****************************************************************************/
#ifndef MAC_OS_X_VERSION_10_8
@interface NSByteCountFormatter (IntroducedInMountainLion)
+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle;
@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.;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment