I am using Error Handling Method globally in appDelegate method to caught exceptions.
Code:
//In appDelegate.m
static void uncaughtExceptionHandler(NSException *exception)
{
printf("\n ===== In uncaughtExceptionHandler Method =======");
NSArray *stack = [exception callStackReturnAddresses];
NSLog(@"======== Exception *************%@", stack);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Exception Occured"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
// Override point for customization after application launch.
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
}
I am implementing an Alert in the uncaughtExceptionHandler Method. But I am getting Error as "self " undeclared.
Can Anyone Please Suggest 开发者_如何学JAVAhow to implement Alert when the uncaughtExceptionHandler is called.
thanks in Advance.
Try implementing this Handle Uncaught Exception
self
is undefined within a C
function. If you want to make the application delegate the delegate for your alert view then you should probably replace self
with [[UIApplication sharedApplication] delegate]
.
精彩评论