Corrupted stack/heap under debugger when simulatin

2019-02-27 20:47发布

问题:

I'm using Xcode 6.3.1. I'm trying to track a weird issue in an app and now I'm seeing that local variables seem to be incorrectly initialised. When I hit a breakpoint at the line where a local variable is defined and initialised at the same time, it is actually shown as an existing local variable, but with a corrupt value:

Has anyone else seen this? In another run the variable was actually showing in the variable view as being an NSDate !!!

回答1:

A breakpoint is actually before the line it appears on; that line has not yet executed. You are thus looking too soon at this variable. It has no meaningful value until after you step past the line where it is initialized. You are still before that line so its value is random garbage.