How to send a message to an object in lldb console?

对着背影说爱祢 提交于 2019-12-04 15:44:33

问题


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];


回答1:


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]

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]

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]


来源:https://stackoverflow.com/questions/15144892/how-to-send-a-message-to-an-object-in-lldb-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!