MythTV  master
util-osx.mm
Go to the documentation of this file.
1 //
2 // util-osx.mm
3 // MythTV
4 //
5 // Created by Jean-Yves Avenard on 2/08/2015.
6 // Copyright (c) 2015 Jean-Yves Avenard. All rights reserved.
7 //
8 
9 #include "util-osx.h"
10 
11 #import <Foundation/NSDictionary.h>
12 #import <Foundation/NSString.h>
13 #import <Foundation/NSArray.h>
14 
15 extern "C" {
16 
17 static int intAtStringIndex(NSArray *array, int index)
18 {
19  return [(NSString *)[array objectAtIndex:index] integerValue];
20 }
21 
22 
23 void GetOSXVersion(int32_t* aMajorVersion, int32_t* aMinorVersion)
24 {
25  *aMajorVersion = *aMinorVersion = 0;
26  NSString* versionString = [[NSDictionary dictionaryWithContentsOfFile:
27  @"/System/Library/CoreServices/SystemVersion.plist"] objectForKey:@"ProductVersion"];
28  NSArray* versions = [versionString componentsSeparatedByString:@"."];
29  NSUInteger count = [versions count];
30  if (count > 0)
31  {
32  *aMajorVersion = intAtStringIndex(versions, 0);
33  if (count > 1)
34  {
35  *aMinorVersion = intAtStringIndex(versions, 1);
36  }
37  }
38 }
39 
40 }
static int intAtStringIndex(NSArray *array, int index)
Definition: util-osx.mm:17
void GetOSXVersion(int32_t *aMajorVersion, int32_t *aMinorVersion)
Definition: util-osx.mm:23