如何向lldb控制台中的对象发送消息? [英] How to send a message to an object in lldb console?
问题描述
说我有指向一个对象' 0x20c28010
'的指针。如何在调试器控制台(lldb)中发送此消息?如: [0x20c28010 doSomething];
Say that I have the pointer to an object '0x20c28010
'. How can I send this object a message in the debugger console (lldb)? As in: [0x20c28010 doSomething];
推荐答案
不返回任何东西,或返回一个你不关心的指针,整数或浮点类型,你可以这样做:
If the message doesn't return anything, or returns a pointer, an integer or a floating-point type that you don't care about, you can do this:
p (void)[0x20c28010 doSomething]
如果你关心返回类型,或者返回类型是 struct
,则需要转换为正确的返回类型。示例:
If you care about the return type, or the return type is a struct
, you need to cast to the correct return type. Examples:
p (int)[0x20c28010 length]
p (float)[0x20c28010 scale]
p (CGPoint)[0x20c28010 origin]
如果消息返回指向Objective-C对象或Core Foundation类型,可以使用 po
打印返回对象的描述:
If the message returns a pointer to an Objective-C object or Core Foundation type, you can use po
to print the returned object's description:
po [0x20c28010 doSomething]
这篇关于如何向lldb控制台中的对象发送消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!