Skip to content

Instantly share code, notes, and snippets.

@ccgus
Created October 1, 2014 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccgus/a1891cd963c365bc3cef to your computer and use it in GitHub Desktop.
Save ccgus/a1891cd963c365bc3cef to your computer and use it in GitHub Desktop.
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;
*/
}
if ((TSSystemVersion() >= 0x10100)) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment