Skip to content

Instantly share code, notes, and snippets.

@ccgus ccgus/gist:6384865
Created Aug 30, 2013

Embed
What would you like to do?
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
You can’t perform that action at this time.