Reputation: 1535
I'm trying to draw something simple on screen when NSSetUncaughtExceptionHandler
gets called but nothings happen.
Is there any other way to catch an exception and quickly draw something on screen?
NSSetUncaughtExceptionHandler(&exceptionHandler);
void exceptionHandler(NSException *exception)
{
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(10.0, 10.0)];
[path moveToPoint:CGPointMake(10.0, 10.0)];
[path addLineToPoint:CGPointMake(10.0, 450.0)];
[path addLineToPoint:CGPointMake(310.0, 450.0)];
[path addLineToPoint:CGPointMake(310.0, 10.0)];
[path addLineToPoint:CGPointMake(10.0, 10.0)];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [path CGPath];
shapeLayer.strokeColor = [[UIColor blueColor] CGColor];
shapeLayer.lineWidth = 3.0;
shapeLayer.fillColor = [[UIColor clearColor] CGColor];
[APP_DELEGATE_WINDOW.rootViewController.view.layer addSublayer:shapeLayer];
[APP_DELEGATE_WINDOW makeKeyAndVisible];
}
Upvotes: 2
Views: 188
Reputation: 7219
Like Rivera said, you won't be able to rescue the application at this stage, but if you really needed to draw something here, you could probably launch another process (which you would have to design) just to show this image.
Upvotes: 1
Reputation: 264
I think Rivera is right, about NSSetUncaughtExceptionHandler
. And maybe you need to write: [path fill];
P.S : I'm sorry that i write here, comments disabled, small reputation...
Upvotes: 1
Reputation: 10938
I'm not sure that the NSSetUncaughtExceptionHandler
is a good place to draw stuff on the screen.
Sets the top-level error-handling function where you can perform last-minute logging before the program terminates.
Most crash reporters carefully log the trace and try not to "touch" anything besides.
If you really want to draw something (what?) you should maybe catch a particular exception first. Just not any uncaught exception.
Upvotes: 1