4

我的应用程序在模拟器中运行良好......但不是在真实设备上......而且我有越狱的 iphone,所以我无法通过设备进行调试......如果我使用尝试捕捉这样的东西

@try
{
Statements
}

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

我的应用程序会在崩溃前在 alertview 上显示错误吗?

如果不是我怎么能找到错误在哪里?

4

3 回答 3

4

捕获异常意味着您正在对即将发生的“错误”做出响应,并且它不会使应用程序崩溃,这就是捕获异常的重点——告诉如何处理出现错误的情况,这样您的应用程序就不会崩溃,所以是的,警报视图将显示...

于 2009-08-21T14:49:28.960 回答
0

只要您的 @catch 块在尝试构建UIAlertView. 确保您releaseautorelease它,并支持UIAlertViewDelegate协议。

于 2009-08-21T15:13:54.007 回答
0

尝试这个:

UIAlertView *alert = [[UIAlertView alloc]
 initWithTitle:[ex name]
 message:[ex reason]
 delegate:self
 cancelButtonTitle:@"OK"
 otherButtonTitles: nil];
于 2009-08-24T15:38:57.800 回答