NSRangeException:调用堆栈不显示行号 [英] NSRangeException: Call Stack Not Showing Line Number

查看:123
本文介绍了NSRangeException:调用堆栈不显示行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下索引超出边界错误:

I am getting the following index out of bounds error:

*** Terminating app due to uncaught exception 'NSRangeException', reason: 
'*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x2263052 0x24c7d0a 0x224fdb8 0x2f4a7 0x2264ec9 0x81e299 0x81e306 0x75aa30 
0x75ac56 0x741384 0x734aa9 0x39a9fa9 0x22371c5 0x219c022 0x219a90a 0x2199db4 
0x2199ccb 0x39a8879 0x39a893e 0x732a9b 0x1e5b 0x1dc5 0x1)


$ b $我知道错误是什么意思,但我发现这些错误很难解决,因为某些原因,调用堆栈并没有告诉我正在调用数组的代码行。这是来自线程1的调用堆栈:

I know exactly what the error means, but I find these errors very difficult to fix because for some reason the call stack isn't telling me the line of code where the array was being called. Here is the call stack from thread 1:

#0  0x9706d9c6 in __pthread_kill ()
#1  0x93e2cf78 in pthread_kill ()
#2  0x93e1dbdd in abort ()
#3  0x02859e78 in dyld_stub__Unwind_DeleteException ()
#4  0x0285789e in default_terminate() ()
#5  0x024c7f4b in _objc_terminate ()
#6  0x028578de in safe_handler_caller(void (*)()) ()
#7  0x02857946 in __cxa_bad_typeid ()
#8  0x02858b3e in __cxa_current_exception_type ()
#9  0x024c7e49 in objc_exception_rethrow ()
#10 0x02199e10 in CFRunLoopRunSpecific ()
#11 0x02199ccb in CFRunLoopRunInMode ()
#12 0x039a8879 in GSEventRunModal ()
#13 0x039a893e in GSEventRun ()
#14 0x00732a9b in UIApplicationMain ()
#15 0x00001e5b in main

正如你可以看到这个调用堆栈不是很有帮助,因为它没有显示我的代码中的任何方法。此外,错误中显示的调用堆栈有22个内存地址,而来自线程1的堆栈只有15个,并且地址根本不匹配。没有其他线程似乎没有任何有用的信息。

As you can see this call stack is not very helpful because it doesn't show any methods from my code. Also, the call stack shown in the error has 22 memory addresses, while the stack from thread 1 only has 15, and the addresses don't match at all. No other threads seem to contain any useful information.

如何从错误中看到第一个调用堆栈的线程(一个有22个地址的线程),所以我可以找到导致这个错误的行?也许我的构建设置中有不正确的设置导致相关堆栈不可检索?

How is it possible to see the thread of the "First throw call stack" from the error (the one with 22 addresses), so I can find the line causing this error? Perhaps I have something set incorrectly in my Build Settings that is causing the relevant stack to not be retrievable?

如果有人可以指出我在正确的方向,我会非常感谢

If someone could point me in the right direction on this I'd be very grateful. Trying to locate the offending line manually is quite tedious.

谢谢!

推荐答案

打开调试器,并在抛出异常时设置断点,这样您就可以确切地知道哪一行代码是一个混蛋。

turn on the debugger and set a breakpoint on whenever an exception is thrown, this way you exactly know which line of code is being a jerk.

objc_exception_throw

objc_exception_throw

或者,[NSException raise];

Alternatively, [NSException raise];

查看以下问题:将断点添加到objc-exception-throw

这篇关于NSRangeException:调用堆栈不显示行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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