开发者

problem in Error handling method in iPhone sdk

开发者 https://www.devze.com 2023-03-13 01:13 出处:网络
I am using Error Handling Method globally in appDelegate method to caught exceptions. Code: //In appDelegate.m

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].

0

精彩评论

暂无评论...
验证码 换一张
取 消