问题
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