Created
April 6, 2017 21:12
-
-
Save jaylyerly/266710aed54900baa194f14f10153551 to your computer and use it in GitHub Desktop.
This implementation of main() for a Mac application dynamically switch the AppDelegate at runtime based on the presence of the TestingAppDelegate class, which is only available during unit testing.
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
#import <Cocoa/Cocoa.h> | |
int main(int argc, char *argv[]) | |
{ | |
if (NSClassFromString(@"AppNameTests.TestingAppDelegate") != nil) { | |
id appDelegate = [[NSClassFromString(@"AppNameTests.TestingAppDelegate") alloc] init]; | |
NSApplication * application = [NSApplication sharedApplication]; | |
[application setDelegate:appDelegate]; | |
[NSApp run]; | |
} else { | |
return NSApplicationMain(argc,(const char **) argv); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment