Last active
October 18, 2016 09:00
-
-
Save TheCodedSelf/de2c9334b327be1b642c8c587f5113c4 to your computer and use it in GitHub Desktop.
Wrap Objective-C Main method in a try-catch block for exception handling
This file contains hidden or 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
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
@try { | |
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | |
} @catch (NSException *exception) { | |
#if DEBUG | |
NSLog(@"\n\n********************"); | |
NSLog(@"UNHANDLED EXCEPTION:"); | |
NSLog(@"%@", exception); | |
NSLog(@"Stack trace: %@", [exception callStackSymbols]); | |
NSLog(@"\n********************"); | |
#endif | |
[exception raise]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment