问题描述
我正在使用X代码3.1 iphone SDK 3.0 beta 5在iphone(OS 2.0)上调试我的应用程序.我的应用程序崩溃,提示信息 *由于未捕获的异常'NSRangeException'而终止应用程序,原因:'* -[NSCFArray insertObject:atIndex:]:超出范围(8)的索引(8)'2009-05-23 17:13:32.304 myApp [405:5a07]堆栈:(808163835,806099672,807978623,807978527,812332907,812067179,812067103,126035,812081649,812081343,826526801)
I am debugging my application on iphone (OS 2.0) using X-code 3.1 iphone SDK 3.0 beta 5 . My application crashes giving message* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray insertObject:atIndex:]: index (8) beyond bounds (8)'2009-05-23 17:13:32.304 myApp[405:5a07] Stack: ( 808163835, 806099672, 807978623, 807978527, 812332907, 812067179, 812067103, 126035, 812081649, 812081343, 826526801)
在gdb中,当我发出命令时(gdb)信息行126035行号126035超出了"/Users/videomac/manish/EXPLab/2009-05-18-12-27 myApp/main.m"的范围.
In gdb when I give commands(gdb) info line 126035Line number 126035 is out of range for "/Users/videomac/manish/EXPLab/2009-05-18-12-27 myApp/main.m".
(gdb)信息行* 126035"/Users/videomac/manish/EXPLab/2009-05-18-12-27 myApp/Classes/PlaybackThread/Playback.m"的第527行始于地址0x1ec52<-[[Playback startPlaybackThread:] + 514>0x1ec6a<-[播放开始播放回播线程:] + 538>.
(gdb) info line *126035Line 527 of "/Users/videomac/manish/EXPLab/2009-05-18-12-27 myApp/Classes/PlaybackThread/Playback.m" starts at address 0x1ec52 <-[Playback startPlaybackThread:]+514> and ends at 0x1ec6a <-[Playback startPlaybackThread:]+538>.
确实意味着崩溃是由于我的方法[Playback startPlaybackThread:]中的代码引起的那么"+514"和"+538"的含义是什么呢?
does that means the crash is due to code in my method [Playback startPlaybackThread:]then what is meaning of the no +514 and +538 do they signify line no?
还有其他方法可以确定崩溃原因吗?
Is there any other way to locate reason of crashes?
推荐答案
查找异常发生位置的最简单方法是在gdb中的-[NSException提高]和objc_exception_throw上设置断点.这样一来,您将立即中断,然后可以检查堆栈.
The easiest way to find where your exception is happening is to set breakpoints on -[NSException raise] and objc_exception_throw in gdb. Then you'll break as soon as it happens, and you can examine the stack at that point.
这篇关于在Objective C代码中查找异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!