I tried using two methods to throw exceptions. The first is with the try trick, and the second is with the following code in Appdelegate.
void onUncaughtException(NSException* exception)
{
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSSetUncaughtExceptionHandler(&onUncaughtException);
}
The advantage of the second method is that we do not need to implement try catch blocks in each method.
The first one gets an exception, prints it, but does not crash the application .. But the second catches the exception, and causes the application to crash .
Is there a way to use the second method to throw exceptions without crashing the application.
source
share