在 xcode 中使用 try catch 块在真实设备上显示错误吗?
我的应用程序在模拟器中运行良好...但不是在真实设备上...并且我有越狱的 iPhone,所以我无法通过设备进行调试...如果我使用 try catch 这样的东西,
@try
{
Statements
}
@catch (NSException *ex) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",ex]
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
我的应用程序将在警报视图上显示错误崩溃之前?
如果不是,我怎样才能找到错误在哪里?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
捕获异常意味着您正在做一些事情来响应出现的“错误”,并且它不会使应用程序崩溃,这就是捕获异常的要点 - 告诉如何处理出现错误的情况,以便您的应用程序不会崩溃,所以是的警报视图将显示...
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...
只要您的 @catch 块在尝试构建
UIAlertView
时不抛出任何异常,就可以正常工作。确保release
或autorelease
它,并支持UIAlertViewDelegate 协议。That will work so long as your @catch block doesn't throw any exceptions while trying to build the
UIAlertView
. Make sure yourelease
orautorelease
it, and support the UIAlertViewDelegate protocol.试试这个:
Try this: