Arrays show up in Xcode 4 debugger as empty even though they aren't
I had been having some issues debugging some code, so I wrote this little piece to test it out:
NSMutableArray *output = [NSMutableArray array];
while (true) {
NSMutableArray *input = [NSMutableArray array];
for (int i = 0; i < 30; i++) {
[input addObject:[NSNumber numberWithInt:i]];
}
[output addObject:[NSArray arrayWithArray:input]];
NSLog(@"%@, %@", input, output);
}
I stuck a breakpoint on the line with the NSLog
and found out some interesting stuff. Going into the variable view, I opened up input and it correctly showed it as being filled with NSNumber objects. I then opened up output, which correctly showed as containing one array. However, upon expanding this array, it showed as being empty.
The NSLog, however, showed a different story. It correctly displayed the multidimensional output array as containing arrays filled with NSNumbe开发者_如何学运维rs. Do multidimensional arrays not work with the variable preview in the debugger? Here's an image of the problem:
I'm utterly baffled by this. Does anyone else have this problem?
I have filed bug report on this to Apple for several versions of Xcode and back in the Project Builder days. It has always been reported as a duplicate. So obviously it is a known bug, but of low priority or very hard to fix.
The same issue exist with the other container classes like NSDictionary
and NSSet
as well, so it not specific to NSArray
.
I suggest you file a report as well over at http://bugreport.apple.com to put more pressure on the issue. And in the mean time rely on po
or NSLog
for most of the container classes debugging needs.
精彩评论