views:

25

answers:

1

I have a button and would like to know its enabled state while stepping through code. This doesn't work in the debugger:

po self.myButton.enabled

It prints:

There is no member named enabled.

Is there another way to print out its state?

+3  A: 

gdb doesn't know dot-syntax for properties, but it will evaluate method calls. -[UIButton enabled] returns a BOOL, which is a scalar type, not an object, so you should use p with a type cast, like this:

p (BOOL)[[self myButton] enabled]

If the property you want to inspect is an object, you can use po without the type cast, like this:

po [[self myButton] font]
cduhn
I keep getting the same message: Target does not respond to this message selector.
4thSpace
Aha. The UIControl documentation declares the enabled property as "@property(nonatomic, getter=isEnabled) BOOL enabled". It doesn't use the default getter method. So try "p (BOOL)[[self myButton] isEnabled]".
cduhn
Great tip. And you are very right. Thanks.
4thSpace