在 xcode 中使用 try catch 块在真实设备上显示错误吗?

发布于 2024-08-02 11:08:20 字数 470 浏览 3 评论 0原文

我的应用程序在模拟器中运行良好...但不是在真实设备上...并且我有越狱的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苹果你个爱泡泡 2024-08-09 11:08:20

捕获异常意味着您正在做一些事情来响应出现的“错误”,并且它不会使应用程序崩溃,这就是捕获异常的要点 - 告诉如何处理出现错误的情况,以便您的应用程序不会崩溃,所以是的警报视图将显示...

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

孤千羽 2024-08-09 11:08:20

只要您的 @catch 块在尝试构建 UIAlertView 时不抛出任何异常,就可以正常工作。确保releaseautorelease它,并支持UIAlertViewDelegate 协议。

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.

青衫儰鉨ミ守葔 2024-08-09 11:08:20

试试这个:

UIAlertView *alert = [[UIAlertView alloc]
 initWithTitle:[ex name]
 message:[ex reason]
 delegate:self
 cancelButtonTitle:@"OK"
 otherButtonTitles: nil];

Try this:

UIAlertView *alert = [[UIAlertView alloc]
 initWithTitle:[ex name]
 message:[ex reason]
 delegate:self
 cancelButtonTitle:@"OK"
 otherButtonTitles: nil];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文