如何在IOS 5中捕获所有异常? [英] How can I catch all exceptions in IOS 5?

查看:152
本文介绍了如何在IOS 5中捕获所有异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与我的应用程序在启动时崩溃的问题作斗争。当试图在iPhone模拟器中运行我的应用程序时,它立即在主函数中断。我无法确定为什么会这样。在我的applicationDelegate中,我试图通过使用NSSetUncaughtExceptionHandler来捕获异常。

I am battling an issue in which my application crashes while launching. When trying to run my application in the iPhone simulator it immediately breaks in the main function. I cannot determine why this is. In my applicationDelegate I am attempting to catch the exception by using NSSetUncaughtExceptionHandler.

    void uncaughtExceptionHandler(NSException *exception){
    NSLog(@"%@",[exception reason]);
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{  
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
    return YES;
}

这似乎没有帮助,因为我的应用程序仍在main()中断似乎永远不会调用application:didFinishLaunchingWithOptions:

This does not seem to help as my application still breaks in main() and never seems to call application:didFinishLaunchingWithOptions:

我还尝试在用户级别设置全局断点objc_exception_throw。同样,应用程序似乎在main()上突破了

I have also tried to set the global breakpoint, objc_exception_throw at the user level. Again the application just seems to break on main()

有人可以提供一些我可以用来尝试追踪这个问题的技巧或窍门吗?

Can someone provide me with some tips or tricks I can use to try and track down this problem?

非常感谢!

推荐答案

在XCode中,转到断点导航器(cmd) +6)。

In XCode, go to your Breakpoint Navigator (cmd+6).

在左下角单击加号按钮,单击添加异常断点。选择所有异常和On Throw。

In the bottom left click on the plus button, click on add Exception Breakpoint. Select All exceptions and On Throw.

这应该创建一个断点,帮助您识别生成异常的位置。

This should create a breakpoint that will help you identify where any exceptions are being generated.

这篇关于如何在IOS 5中捕获所有异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆