Arrays appear in the Xcode 4 debugger as empty, even if they are not

I had some problems debugging some code, so I wrote this little piece to check it:

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 hooked a line breakpoint using NSLog and found some interesting things. Going into the variable view, I opened the input, and it correctly showed it as filled with NSNumber objects. Then I opened the output, which correctly showed as containing one array. However, when expanding this array, it showed that it is empty.

However, NSLog revealed a different story. It correctly displayed the multidimensional output array as containing arrays filled with NSNumbers. Don't multidimensional arrays work with previewing a variable in the debugger? Here's a picture of the problem:

enter image description here

I am completely puzzled by this. Does anyone else have this problem?

+4
source share
1 answer

I sent an error report to Apple for several versions of Xcode and back in the days of Project Builder. It has always been reported as a duplicate. Thus, it is obvious that this is a known error, but with a low priority or very difficult to fix.

The same problem exists for other container classes such as NSDictionary and NSSet , so this does not apply to NSArray .

I suggest you send a report also to http://bugreport.apple.com to put more pressure on the problem. And at the same time, rely on po or NSLog for most container class debugging tasks.

+3
source

Source: https://habr.com/ru/post/1369255/


All Articles