insertObject:atIndex: 在 iOS6 上的异常 [英] Exception with insertObject:atIndex: on iOS6

查看:17
本文介绍了insertObject:atIndex: 在 iOS6 上的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iOS6 上收到以下异常(在带有 CoreData 的应用上):

I'm getting the following Exception on iOS6 (on an App with CoreData):

"2012-10-15 10:21:28.952 MyApp[68650:c07] * 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'* -[__NSArrayM insertObject:atIndex:]: 对象不能为零'* 首先抛出调用栈:(0x28e6012 0x2659e7e 0x2899b6a 0x2899a20 0x1646941 0x1642c67 0x164f846 0x164f908 0x6c540 0x2057e83 0x28a5376 0x28a4e06 0x288ca82 0x288bf44 0x288be1b 0x33967e3 0x3396668 0x15a165c 0x13a22 0x2845)libc++abi.dylib: 终止调用抛出异常"

"2012-10-15 10:21:28.952 MyApp[68650:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil' * First throw call stack: (0x28e6012 0x2659e7e 0x2899b6a 0x2899a20 0x1646941 0x1642c67 0x164f846 0x164f908 0x6c540 0x2057e83 0x28a5376 0x28a4e06 0x288ca82 0x288bf44 0x288be1b 0x33967e3 0x3396668 0x15a165c 0x13a22 0x2845) libc++abi.dylib: terminate called throwing an exception"

这不会发生在 iOS5 上,所以在 iOS6 上发生了一些我不明白的事情.我在调用 insertObject:atIndex: 的每个点上设置了一个断点:但这些没有被调用 - 它必须是这个 libc++abi.dylib 中的某个东西,它被调用并崩溃.有谁知道可能出了什么问题?

This doesn't happen on iOS5, so something happens on iOS6 what I don't understand. I set a Breakpoint on every point where I call insertObject:atIndex: but these are not called - it have to be something in this libc++abi.dylib which gets called and crashes. Does anyone know what could be wrong?

谢谢

推荐答案

崩溃的原因是你试图插入的对象是nil.这意味着它没有正确实例化.这反过来意味着在您遇到该异常之前出了问题.

The reason for the crash is that the object you are trying to insert is nil. This means it is not properly instantiated. This in turn means something has gone awry before you reached that exception.

您能否发布alloced 和init 初始化您试图插入的对象的代码?

Could you post the code that alloced and initialized the object you were trying to insert?

为了找到相关的代码行,请尝试以下操作:转到 Xcode 项目中的异常"选项卡:

In order to find the relevant line of code, please try the following: Go to the "Exception" tab in your Xcode project:

然后单击+"按钮(在页面底部)并选择添加异常断点...".将所有设置保留为默认值,然后单击完成".

Then click the "+" button (at the bottom of the page) and select "Add Exception Breakppoint ...". Leave all settings to their defaults and click "Done".

如果您重新运行您的项目,它现在应该在引发异常之前停止在相关代码行.然后,您可以向上移动调用堆栈并识别您在代码中调用负责此行为的库函数的位置.然后尝试查看此时是否所有对象都正确初始化.

If you rerun your project it should now stop at the relevant line of code before the exception is thrown. Then you can move up the call-stack and identify from where in your code you called the library function that is responsible for this behavior. Then try to see if all objects are correctly initialized at this point.

这篇关于insertObject:atIndex: 在 iOS6 上的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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