Skip to content

Instantly share code, notes, and snippets.

@TheCodedSelf
Last active October 18, 2016 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheCodedSelf/de2c9334b327be1b642c8c587f5113c4 to your computer and use it in GitHub Desktop.
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
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