views:

1270

answers:

3

my application is running fine in simulator...but not on real device....and i have jailbroken iphone so i am unable to debug through device...if i use try catch something like this

@try
{
Statements
}

@catch (NSException *ex) {
 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",ex]
               delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
 [alert show];
}

will my application show error on alertview before crashing?

if not how could i find where is the bug?

+1  A: 

Catching the exception means you are doing something in response to this "error" coming about and it wont crash the application , thats the point of catching exceptions-to tell how to handle cases where errors arrise so your app wont crash, so yes the alert view will show...

Daniel
A: 

That will work so long as your @catch block doesn't throw any exceptions while trying to build the UIAlertView. Make sure you release or autorelease it, and support the UIAlertViewDelegate protocol.

slf
even if he doesnt implement the protocol the app wont crash until he clicks on the button so the alert will still show
Daniel
that's true, just trying to mention any "gotchas"
slf
using this caus my application to become very slow and it does not show any alertview...am i doing something wrong???how do i show nsexception as alertview message
Rahul Vyas
A: 

Try this:

UIAlertView *alert = [[UIAlertView alloc]
 initWithTitle:[ex name]
 message:[ex reason]
 delegate:self
 cancelButtonTitle:@"OK"
 otherButtonTitles: nil];
slf
how do i show alert when application crashed...it's showing error in gdb
Rahul Vyas
your original post said that you could not use attach GDB, you've confused me
slf