Objective-C: instance variables out of scope in debugger

前端 未结 1 379
失恋的感觉
失恋的感觉 2020-12-09 13:52

I have a superclass and a subclass, both of which define instance variables.

Rough outline of superclass:

/* GenericClass.h */
@interface GenericCla         


        
相关标签:
1条回答
  • 2020-12-09 14:43

    GDB is not an Objective-C compiler. The compiler knows about things like lexical scope within Objective-C methods, but GDB does not. It does, however, understand local variables.

    In Objective-C, every method has an implicit self parameter passed to it when it's called. So when you look at self->str, GDB is interpreting that like it would interpret any other local variable evaluation.

    When you try to evaluate str on its own, GDB will look for a local variable called str and, not finding one, reports that it's not in scope. This is not an error; this is the expected behavior.

    0 讨论(0)
提交回复
热议问题