特定 Segue 的 NSRangeException

NSRangeException at particular Segue

我有这个特殊的 segue,一直给我 NSRangeException。我在 prepareForSegue 中根本没有代码。我在该视图控制器的 viewdidload 中放置了一个断点,它可以毫无问题地执行。似乎异常发生在IOS系统代码中。

这是异常的详细信息

2015-09-16 07:21:24.939 Vote Strategic[7523:1117149] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array' *** First throw call stack: ( 0 CoreFoundation 0x000000010a699c65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010c204bb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010a583093 -[__NSArrayM objectAtIndex:] + 227 3 My Strategic 0x000000010a008cfa _TPAo13 + 42 4 My Strategic 0x000000010a009c35 _TTRXFo_dSi_aPSs9AnyObject__XFo_dSi_oPS_ + 21 5 My Strategic 0x000000010a0094ec _TFFC14My_Strategic4Rest9getRidingFS0_FSST_U_FTGSQCSo13NSURLResponse_GSQCSo6NSData_GSQCSo7NSError__T_ + 1260 6 My Strategic 0x000000010a009cea _TTRXFo_oGSQCSo13NSURLResponse_oGSQCSo6NSData_oGSQCSo7NSError__dT__XFdCb_dGSQS__dGSQS0__dGSQS1___dT__ + 90 7 CFNetwork 0x000000010c8a98c5 67+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]_block_invoke_2 + 155 8 Foundation 0x000000010ab5a57f __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 7 9 Foundation 0x000000010aa9b0b2 -[NSBlockOperation main] + 98 10 Foundation 0x000000010aa7d774 -[__NSOperationInternal _start:] + 645 11 Foundation 0x000000010aa7d383 __NSOQSchedule_f + 184 12 libdispatch.dylib 0x000000010dcfe614 _dispatch_client_callout + 8 13 libdispatch.dylib 0x000000010dce56a7 _dispatch_queue_drain + 2176 14 libdispatch.dylib 0x000000010dce4cc0 _dispatch_queue_invoke + 235 15 libdispatch.dylib 0x000000010dce83b9 _dispatch_root_queue_drain + 1359 16 libdispatch.dylib 0x000000010dce9b17 _dispatch_worker_thread3 + 111 17 libsystem_pthread.dylib 0x000000010e06b637 _pthread_wqthread + 729 18 libsystem_pthread.dylib 0x000000010e06940d start_wqthread + 13 ) libc++abi.dylib: terminating with uncaught exception of type NSException

请将异常断点和 运行 置于调试模式以在崩溃的确切行停止。

很明显,您正试图从一个注定会崩溃的空数组中访问对象。始终建议在访问其元素之前检查数组大小。