Note that there are some explanatory texts on larger screens.

plurals
  1. POVariable declarations inside of a method causing gdb garbage output prior to instantiation
    primarykey
    data
    text
    <p>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.</p> <p>The structure of one of my methods looks like this:</p> <pre><code>{ // code that checks if this method needs to do something // ... // further down, I instantiate e.g. foo as an NSArray NSArray *foo = bar; // ... } </code></pre> <p>If I debug the above code, I happen to have a <code>NSDictionary</code> called sizes. Because I am instantiating foo some lines into the method, I keep getting these errors in console up until foo is created:</p> <pre><code>-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x541cb90 </code></pre> <p>The reason why this happens is that <strong>both sizes and foo are pointing at the same memory 0x541cb90</strong>. 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. </p> <p>This may be related to <a href="https://stackoverflow.com/questions/4284277/libxcodedebuggersupport-dylib-is-missing-in-ios-4-2-1-development-sdk">libXcodeDebuggerSupport.dylib is missing in iOS 4.2.1 development SDK</a></p> <p>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...?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload