2011-02-24 45 views
3

我使用@dynamic屬性結合-forwardInvocation:在運行時生成屬性(如this answer中所述)。現在,當我嘗試用這樣的屬性生效(假設name就是這樣的一個動態屬性)在GDB我總是得到這樣的:@動態屬性在GDB中不受支持?

(gdb) call (void) [myObject setName:@"foo"] 
Target does not respond to this message selector. 

(gdb) po [myObject name] 
Target does not respond to this message selector. 

是否有GDB的開關,使這項工作?

+0

你如何使用forwardInvocation:在這種情況下,關於你的實際屬性getter和setter? – Ryan 2011-02-24 20:56:23

+0

@Ryan,就像在鏈接的答案中一樣,我也使用字典作爲數據存儲。 – 2011-02-24 21:20:59

+0

有可能gdb沒有爲其命令行界面實現中的這種情況做好準備。你是否還在你的對象上實現了-methodSignatureForSelector:?另外,退一步說,如果你的myObject變量沒有指向你的類的有效實例,我希望你從gdb得到這個消息。當你運行這個命令時,gdb會打印你期望的類名:「po [myObject class]」? – Ryan 2011-02-24 21:32:45

回答

8

您可以使用po [myObject performSelector:@selector(name)]作爲解決方法,雖然它很尷尬。

相關問題