Skip to content

Instantly share code, notes, and snippets.

@thetzel
Created July 3, 2013 20:44
Show Gist options
  • Save thetzel/5922639 to your computer and use it in GitHub Desktop.
Save thetzel/5922639 to your computer and use it in GitHub Desktop.
Fork app in main.m between old codebase for iOS5/6 and new for iOS7+
NSUInteger DeviceSystemMajorVersion();
NSUInteger DeviceSystemMajorVersion() {
static NSUInteger _deviceSystemMajorVersion = -1;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
});
return _deviceSystemMajorVersion;
}
#define OLDSCHOOL (DeviceSystemMajorVersion() < 7)
int main(int argc, char *argv[]) {
if (OLDSCHOOL) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
[pool release];
return retVal;
}
else
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, @"FlatAppDelegate");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment