Created
August 30, 2013 00:04
-
-
Save ccgus/6384865 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SInt32 TSSystemVersion(void) { | |
static dispatch_once_t once; | |
static int TSSystemVersionVal = 0x00; | |
dispatch_once(&once, ^{ | |
NSDictionary *d = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]; | |
NSString *prodVersion = [d objectForKey:@"ProductVersion"]; | |
// sanity. | |
FMAssert([prodVersion isKindOfClass:[NSString class]]); | |
if ([[prodVersion componentsSeparatedByString:@"."] count] < 3) { | |
prodVersion = [prodVersion stringByAppendingString:@".0"]; | |
} | |
FMAssert([[prodVersion componentsSeparatedByString:@"."] count] == 3); | |
NSString *junk = [prodVersion stringByReplacingOccurrencesOfString:@"." withString:@""]; | |
char *e = nil; | |
TSSystemVersionVal = (int) strtoul([junk UTF8String], &e, 16); | |
}); | |
return TSSystemVersionVal; | |
//The above replaces this: | |
/* | |
SInt32 v; | |
Gestalt(gestaltSystemVersion, &v); | |
return v; | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment