Last active
October 10, 2015 16:17
-
-
Save ccgus/3716936 to your computer and use it in GitHub Desktop.
Gestalt(gestaltSystemVersion, &v); replacement
This file contains 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
/* | |
if ((TSSystemVersion() >= 0x1074) || (TSSystemVersion() < 0x1070)) { | |
// hurray, no stupid CoreImage stack crasher for lots of images being composited together! | |
} | |
*/ | |
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