This is a really weird one and I'm wondering if I need to change my coding style a bit or if gdb is bugging out on me.
The structure of one of my methods looks like this:
{
// code that checks if this method needs to do something
// ...
// further down, I instantiate e.g. foo as an NSArray
NSArray *foo = bar;
// ...
}
If I debug the above code, I happen to have a NSDictionary
called sizes. Because I am instantiating foo some lines into the method, I keep getting these errors in console up until foo is created:
-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x541cb90
The reason why this happens is that both sizes and foo are pointing at the same memory 0x541cb90. But since I haven't even CREATED foo yet, I can't really do anything about it. The error appears repeatedly until I step into the foo = bar point, where it stops appearing. The reason it appears is I think because it's trying to show me the values for it in the debug variable window to the right.
This may be related to libXcodeDebuggerSupport.dylib is missing in iOS 4.2.1 development SDK
Is it simply bad practice to declare variables "throughout" a method like this? It feels wasteful to declare every variable I ever intend to use inside a method at the very top, but maybe I have to...?