我是iphone開發新手,在開發過程中由於這個錯誤而面臨問題。我無法從它的製作地點追蹤它。objective-c:無法從棧跟蹤中瞭解異常生產者的位置?
app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
*** Call stack at first throw:
(
0 CoreFoundation 0x012dcbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x014315c2 objc_exception_throw + 47
2 CoreFoundation 0x012d26e5 -[__NSArrayM objectAtIndex:] + 261
3 Dispatch 0x0002feeb -[ZoneFareTaxi parseMessage:] + 754
4 Dispatch 0x0002fbf0 -[ZoneFareTaxi initWithMessageString:] + 92
5 Dispatch 0x0003b949 -[ServerConnection onUdpSocket:didReceiveData:withTag:fromHost:port:] + 8862
6 Dispatch 0x0002350e -[AsyncUdpSocket maybeCompleteCurrentReceive] + 458
7 Dispatch 0x-[AsyncUdpSocket doReceive:] + 1364
8 Dispatch 0x00022c60 -[AsyncUdpSocket doReceive4] + 80
9 Dispatch 0x00022add -[AsyncUdpSocket maybeDequeueReceive] + 561
10 Foundation 0x000da7f6 __NSFireDelayedPerform + 441
11 CoreFoundation 0x012bdfe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
12 CoreFoundation 0x012bf594 __CFRunLoopDoTimer + 1220
13 CoreFoundation 0x0121bcc9 __CFRunLoopRun + 1817
14 CoreFoundation 0x0121b240 CFRunLoopRunSpecific + 208
15 CoreFoundation 0x0121b161 CFRunLoopRunInMode + 97
16 GraphicsServices 0x01a4d268 GSEventRunModal + 217
17 GraphicsServices 0x01a4d32d GSEventRun + 115
18 UIKit 0x0036a42e UIApplicationMain + 1160
19 Dispatch 0x000024b4 main + 102
20 Dispatch 0x00002445 start + 53
21 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
訪問你的數組之前,print [yourArray count]; – Maulik
你有一個數組超出邊界的地方。 IE中,你定義了一個包含4個元素的數組,但它試圖訪問第5個元素(或帶有負數的索引)。如果您向我們展示代碼,我可以嘗試爲您找到它。 –
錯誤表示您試圖訪問陣列的無效索引。 – Maulik