iOS: ¿qué está sucediendo con mis variables de instancia?

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.

preguntado el 10 de marzo de 12 a las 00:03

What constitutes 'debugging'? -

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. -

NSLog your int and return it's value. That's what you should care about... -

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. -

Try to define instance variable in interace section, instead of implementation. -

1 Respuestas

It's a bug in the LLVM debugger -- change your debugger to GDB. See La subclase UIViewController no puede asignar una variable de instancia del mismo año, para obtener más información.

contestado el 23 de mayo de 17 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.