NSRangeException-断点不给我任何线索

时间:2018-12-22 15:39:42

标签: ios swift sprite-kit nsrangeexception

请原谅这里的任何错误,我是一名编码爱好者,也是新手问的问题,但我已竭尽全力来查找此错误并失败了。

我在SKScenes之间移动时遇到崩溃,但前提是该应用程序已进入后台模式并从后台模式还原。而且崩溃仅发生在实际设备上,而不发生在模拟器上。控制台的输出是这样的:

2018-12-22 15:17:32.646668+0000 grabbit[22230:5424629] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM removeObjectsInRange:]: range {0, 2} extends beyond bounds [0 .. 0]'
*** First throw call stack:
(0x210febea0 0x2101bda40 0x210f63470 0x210ed32ac 0x2288df1a0 0x2288df438 0x2288b13d8 0x2101bc468 0x2101cc70c 0x2101cc774 0x22880fe18 0x1040764d4 0x2101bc468 0x2101cc70c 0x2101cc774 0x23e1e56cc 0x2288911e8 0x228845c5c 0x104076430 0x104076468 0x1040b92ec 0x1040b9390 0x22886c1b0 0x23e1f418c 0x23e1f53f0 0x23e1d46ec 0x23e2a057c 0x23e2a2f74 0x23e29ba64 0x210f7c1cc 0x210f7c14c 0x210f7ba30 0x210f768fc 0x210f761cc 0x2131ed584 0x23e1b9054 0x1040a9210 0x210a36bb4)
libc++abi.dylib: terminating with uncaught exception of type NSException

我从中收集到一个我试图访问数组中不存在的索引的地方,但是我不知道它在哪里。

我在SO中搜索了类似的错误,并且遇到了引发异常时激活断点的建议。我已经做到了,并且在“旧”场景被取消初始化之后,代码似乎立即中断。似乎在[SKScene dealloc]之后立即在线程中引发了异常。

这似乎是引发异常的代码(这对我完全没有帮助!)

  deinit {
        print("Game Scene deinitialised")
    }

这是否意味着在释放过程中发生了导致崩溃的事情?我很乐意发布一些代码片段,但不知道从哪里开始。 SKScene非常复杂。

这是主线程崩溃时的样子-#17显然出了所有问题

#0  0x00000002101bda08 in objc_exception_throw ()
#1  0x0000000210f63470 in _CFThrowFormattedException ()
#2  0x0000000210ed32ac in -[__NSArrayM removeObjectsInRange:] ()
#3  0x00000002288df1a0 in -[SKSoundSource purgeCompletedBuffers] ()
#4  0x00000002288df438 in -[SKSoundSource dealloc] ()
#5  0x00000002288b13d8 in -[SKPlaySound .cxx_destruct] ()
#6  0x00000002101bc468 in object_cxxDestructFromClass(objc_object*, objc_class*) ()
#7  0x00000002101cc70c in objc_destructInstance ()
#8  0x00000002101cc774 in object_dispose ()
#9  0x000000022880fe18 in -[SKAction dealloc] ()
#10 0x00000001046de4a4 in @objc GameScene.__ivar_destroyer ()
#11 0x00000002101bc468 in object_cxxDestructFromClass(objc_object*, objc_class*) ()
#12 0x00000002101cc70c in objc_destructInstance ()
#13 0x00000002101cc774 in object_dispose ()
#14 0x000000023e1e56cc in -[UIResponder dealloc] ()
#15 0x00000002288911e8 in -[SKNode dealloc] ()
#16 0x0000000228845c5c in -[SKScene dealloc] ()
#17 0x00000001046de400 in GameScene.__deallocating_deinit at /Users/
#18 0x00000001046de438 in @objc GameScene.__deallocating_deinit ()
#19 0x00000001047212ec in NextGameBar.touchesEnded(_:with:) at /Users/
#20 0x0000000104721390 in @objc NextGameBar.touchesEnded(_:with:) ()
#21 0x000000022886c1b0 in -[SKView touchesEnded:withEvent:] ()
#22 0x000000023e1f418c in -[UIWindow _sendTouchesForEvent:] ()
#23 0x000000023e1f53f0 in -[UIWindow sendEvent:] ()
#24 0x000000023e1d46ec in -[UIApplication sendEvent:] ()
#25 0x000000023e2a057c in __dispatchPreprocessedEventFromEventQueue ()
#26 0x000000023e2a2f74 in __handleEventQueueInternal ()
#27 0x000000023e29ba64 in __handleHIDEventFetcherDrain ()
#28 0x0000000210f7c1cc in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#29 0x0000000210f7c14c in __CFRunLoopDoSource0 ()
#30 0x0000000210f7ba30 in __CFRunLoopDoSources0 ()
#31 0x0000000210f768fc in __CFRunLoopRun ()
#32 0x0000000210f761cc in CFRunLoopRunSpecific ()
#33 0x00000002131ed584 in GSEventRunModal ()
#34 0x000000023e1b9054 in UIApplicationMain ()
#35 0x00000001047111e0 in main at /Users/
#36 0x0000000210a36bb4 in start ()

非常感谢您的协助。

0 个答案:

没有答案
相关问题