an0 an0 - 1 month ago 12
Objective-C Question

Why can't LLDB print view.bounds?

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.

an0 an0
Answer

Starting from Xcode 6.3, we have a better solution. In short, you need to import UIKit for LLDB to know about these types: expr @import UIKit. Check out this article to learn some tricks to make your life even easier.

Comments