First, if you have a crash, you have a backtrace. Always provide the backtrace with your question (it'll be in the debugger and can be copy/pasted).
As Vojito implied, the most common cause of crashes like these is related to the over-releasing of objects.
In your case, for(;;)
and for(... in ...)
are not actually exactly the same. The latter is very likely causing the objects within the array to be retained for the duration of iteration or autoreleased upon retrieval (I say "very likely" because I didn't test it -- but it would explain the behavior).
In your code, you are modifying your object graph during iteration with statements like otherBody = contact.bodyB
. If any one of those statements happens to cause one of the items in the array being iterated to be released out from under the array, you would see a crash. Similarly, if the modification of the object graph causes either contact.bodyA
or contact.bodyB
to become a dangling reference, you would see a crash.
All just an educated guess. Post the backtrace and, as Vojito suggested, run under the Allocation instrument in Instruments with zombie detection enabled.