Stopped in the viewDidLoad of a ViewController, you can access the "view" property just as you would in code:
(lldb) expr self.view
(UIView *) $0 = 0x0000000100615150
Now we have the address of a UIView, let's try accessing its properties:
(lldb) expr ((UIView *) 0x0000000100615150).frame
(CGRect) $5 = (origin = (x = 0, y = 0), size = (width = 768, height = 1024))
The property vrs. method notation "should" just be an automatic substitution in the compiler. However, when we don't know the type of the property, using property access in the debugger's expression parser can run into trouble, especially when you chain properties.
The reason for this is that it is actually unsafe (can corrupt the stack of the debugee) if lldb calls a struct returning function (like UIView's "frame" property) using the scalar calling convention. So lldb is extra careful that it knows the types of the elements in an expression before calling it. If lldb can't figure it out from debug info, it may require extra casting to make the type checker happy.
Note, lldb makes one exception to the requirement that we know the types in expressions which may account for the differences you mentioned. If we see:
[<some expression whose type we don't know> someSelector]
as an expression or sub-expression, we will rewrite this as:
[(id) <some expression whose type we don't know> someSelector]
That seemed a reasonable assist, since the only thing it makes sense to send an ObjC message to is an "id". So any mistake will be a nonsensical one and so hopefully less likely. That does mean a chain of method accesses that all return "id" will get resolved when the equivalent . form would fail the type checker.
This is all the messy corners of dealing with incomplete type information at debug time. Note, many of these issues are resolved by either building your program using modules (-fmodule
and -gmodule
) or equivalently by issuing:
(lldb) expression @import UIKit
as part of your debug session. Then lldb will know all the types from UIKit, and the expression parser can do a better job.