0

I have a really simple class, and within the implementation I have this code:

@implementation MyProgram
{
    int myInt;
}

Then in a separate method I have this:

- (void)myMethod
{
    myInt = 0;
}

I noticed this int was giving me problems, so I debugged and stopped it within myMethod. When I hover over the variable, it tells me the following information:

int    $3    17893987392

Obviously, this information (I think) should look like this:

int    myInt    0

Strange thing is, when I re-hover over the variable, the "name" continues to increment by one:

int    $4    17893987392

Can someone shed some light on what is going on?? I upgraded to Xcode 4.3.1 yesterday, and things have been strange ever since.

QED
  • 9,803
  • 7
  • 50
  • 87
achiral
  • 601
  • 2
  • 11
  • 24
  • What constitutes 'debugging'? – CodaFi Mar 10 '12 at 00:34
  • Adding a breakpoint at the relevant line within myMethod and seeing what the value of myInt is before and after it is assigned the value of 0. – achiral Mar 10 '12 at 00:36
  • NSLog your int and return it's value. That's what you should care about... – CodaFi Mar 10 '12 at 00:39
  • Did you try cleaning your project? This might help. XCode may have some intermediate stuff in there. Also, I find that scattering a few NSLogs in there does help sometimes with weird errors like this, not only to give you insight, but they may also force the compiler to recreate object code surrounding the trouble spot and thus clear things up. P.S. I deleted my original answer because I realized it wasn't what you're after. – QED Mar 10 '12 at 00:42
  • 1
    Try to define instance variable in interace section, instead of implementation. – NeverBe Mar 10 '12 at 00:58
  • Perhaps you can try initializing your int in the init method in the .m file. I find that sometime if I leave an iVar uninitialized it behaves weirdly.. – tams Mar 10 '12 at 02:36

1 Answers1

1

It's a bug in the LLVM debugger -- change your debugger to GDB. See UIViewController subclass can't assign instance variable for more information.

Community
  • 1
  • 1
Martin
  • 26
  • 1