Why can't LLDB print view.bounds?

an0 picture an0 · Sep 19, 2013 · Viewed 12.3k times · Source

Things like this drive me crazy when debugging:

(lldb) p self.bounds
error: unsupported expression with unknown type
error: unsupported expression with unknown type
error: 2 errors parsing expression
(lldb) p (CGRect)self.bounds
error: unsupported expression with unknown type
error: unsupported expression with unknown type
error: C-style cast from '<unknown type>' to 'CGRect' is not allowed
error: 3 errors parsing expression
(lldb) p [self bounds]
error: 'bounds' has unknown return type; cast the call to its declared return type
error: 1 errors parsing expression
(lldb) p (CGRect)[self bounds]
(CGRect) $1 = origin=(x=0, y=0) size=(width=320, height=238)
(lldb) You suck!
error: 'You' is not a valid command.
(lldb) …

Why did the first 3 attempts fail? Is there any simpler way to print self.bounds? Thanks.

Answer

youfu picture youfu · Sep 20, 2013

You can access it by

p (CGRect)[view bounds]

or

p view.layer.bounds

view.bounds is actually view.layer.bounds

It seems that the type info of [UIView bounds] is not available to lldb