does using try catch block in xcode show error on real device?
-
19-09-2019 - |
Question
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?
Solution
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...
OTHER TIPS
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.
Try this:
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:[ex name]
message:[ex reason]
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];