问题描述
我得到关于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.
您可以发布 alloc 之前的代码
代码的相关行,请尝试以下方法:在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上的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!