In this game, once the player dies, all of the variables are reinitialized and a tap-to-play label should appear. Instead, the app crashes with the following message:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
So, that seems pretty self-explanatory, however, I haven't been able to narrow the crash down to any single array using breakpoints. In fact, everything seems to be reinitialized just fine. But somewhere between that point and being able to restart the game is where the crash occurs.
I guess my question is, how do I find a bug that doesn't seem to be tied to any particular code - even though it obviously is?
I'm not including code because I don't want a fix for this one problem - I'm more interested in learning how to uncover the problem. Thanks!
Here is the stack trace where the error occurs. FWIW!
libsystem_kernel.dylib`__pthread_kill:
0x182db42e0 <+0>: mov x16, #0x148
0x182db42e4 <+4>: svc #0x80
-> 0x182db42e8 <+8>: b.lo 0x182db4300 ; <+32>
0x182db42ec <+12>: stp x29, x30, [sp, #-0x10]!
0x182db42f0 <+16>: mov x29, sp
0x182db42f4 <+20>: bl 0x182d94bdc ; cerror_nocancel
0x182db42f8 <+24>: mov sp, x29
0x182db42fc <+28>: ldp x29, x30, [sp], #0x10
0x182db4300 <+32>: ret