无法通过lldb评估属性的值

时间:2013-09-18 14:19:41

标签: ios objective-c xcode lldb

在我班上我有一个属性

@property (nonatomic, retain) UIBarButtonItem *allMediaButton;

在我的代码中,我使用setEnabled: setter启用和禁用此控件。

但是在调试窗口中我无法检查属性值

我尝试了不同的方式:

(lldb) po (UIBarItem*)appdelegate.detailViewController.allMediaButton
(UIBarItem *) $1 = 0x08302ed0 <UIBarButtonItem: 0x8302ed0>

(lldb) po (UIBarItem*)appdelegate.detailViewController.allMediaButton.enabled
error: property 'enabled' not found on object of type 'UIBarButtonItem *'
error: 1 errors parsing expression

(lldb) expr (UIBarItem*)appdelegate.detailViewController.allMediaButton.enabled
error: property 'enabled' not found on object of type 'UIBarButtonItem *'
error: 1 errors parsing expression

(lldb) expr ((UIBarItem*)appdelegate.detailViewController.allMediaButton).enabled
error: property 'enabled' not found on object of type 'UIBarItem *'
error: 1 errors parsing expression

(lldb) expr ((UIBarItem*)appdelegate.detailViewController.allMediaButton).enabled
error: property 'enabled' not found on object of type 'UIBarItem *'
error: 1 errors parsing expression

(lldb) po ((UIBarItem*)appdelegate.detailViewController.allMediaButton).enabled
error: property 'enabled' not found on object of type 'UIBarItem *'
error: 1 errors parsing expression

(lldb) po ((UIBarItem*)appdelegate.detailViewController.allMediaButton).isEnabled
error: property 'isEnabled' not found on object of type 'UIBarItem *'
error: 1 errors parsing expression

(lldb) expr ((UIBarItem*)appdelegate.detailViewController.allMediaButton).isEnabled
error: property 'isEnabled' not found on object of type 'UIBarItem *'
error: 1 errors parsing expression

(lldb) expr appdelegate.detailViewController.allMediaButton.isEnabled
error: property 'isEnabled' not found on object of type 'UIBarButtonItem *'
error: 1 errors parsing expression

(lldb) po  appdelegate.detailViewController.allMediaButton.isEnabled
error: property 'isEnabled' not found on object of type 'UIBarButtonItem *'
error: 1 errors parsing expression

(lldb) po  appdelegate.detailViewController.allMediaButton.enabled
error: property 'enabled' not found on object of type 'UIBarButtonItem *'
error: 1 errors parsing expression

(lldb) expr  appdelegate.detailViewController.allMediaButton.enabled
error: property 'enabled' not found on object of type 'UIBarButtonItem *'
error: 1 errors parsing expression

如何查看属性的值?

更新:po @()不起作用:

(lldb) po  @([[[appdelegate detailViewController] allMediaButton] isEnabled])
error: no known method '-isEnabled'; cast the message send to the method's return type
error: 1 errors parsing expression

(lldb) po  @([(UIBarItem)[[appdelegate detailViewController] allMediaButton] isEnabled])
error: C-style cast from 'UIBarButtonItem *' to 'UIBarItem' is not allowed
error: 1 errors parsing expression

(lldb) po  @([(UIBarItem*)[[appdelegate detailViewController] allMediaButton] isEnabled])
error: no known method '-isEnabled'; cast the message send to the method's return type
error: 1 errors parsing expression

(lldb) po  @([((UIBarItem*)[[appdelegate detailViewController] allMediaButton]) isEnabled])
error: no known method '-isEnabled'; cast the message send to the method's return type
error: 1 errors parsing expression

2 个答案:

答案 0 :(得分:1)

你不能(po)像这样打印OBJECT,因为实际上enabled属性不是对象类型,而是SCALAR。您可以尝试po @( your scalar value here )

另一个非常重要的事情是尝试执行以下操作以获取对属性的访问权限而无需强制转换

po @([[[appdelegate detailViewController] allMediaButton] isEnabled])

应该适合你

答案 1 :(得分:0)

而不是

po @(scalar)

使用

p scalar