I want to trace when something changes the size of self.view. What’s the correct format?
(lldb) po self.view
(UIView *) $1 = 0x0a8aba20 <UIView: 0xa8aba20; frame = (0 0; 480 864); autoresize = W+TM+BM; layer = <CALayer: 0xa8aba50>>
(lldb) watch set variable self.view.frame.size.width
error: "self" is a pointer and . was used to attempt to access "view". Did you mean "self->view.frame.size.width"?
(lldb) watch set variable self->view
error: "view" is not a member of "(PlayViewController *) self"
(lldb) watch set variable self->view.frame.size.width
error: "view" is not a member of "(PlayViewController *) self"
I’ve tried the documentation and other lldb watchpoint questions but can’t find anything for this specific case.
Thanks for your help.
The view controller references its view from its
_viewinstance variable.The view doesn’t store its frame directly. It just returns its layer’s `frame’.
The view references its layer from its
_layerinstance variable.The layer doesn’t store the frame either. It computes its frame from its
bounds,position,anchorPoint, andtransform. The size is part ofbounds.The layer doesn’t store its bounds directly in an instance variable. Instead, its
layerinstance variable references an instance of a private C++ class,CA::Layer. The member layout of this class is undocumented.In other words, you can go
self->_view->_layer->layerto get to theCA::Layerinstance, but then you’re stuck because you don’t know where in theCA::Layerto find the bounds.So, trying to use a watchpoint to detect changes to the view’s size is rather difficult.
It is easier to put a breakpoint on
-[CALayer setBounds:].On the simulator
Remember to use the layer address in the breakpoint condition, not the view address.
When the breakpoint is hit, the
CALayerinstance is referenced by((int *)$esp)[1], and the new bounds is*(CGRect *)($esp+12):On the device
Remember to use the layer address in the breakpoint condition, not the view address.
When the breakpoint is hit, the
CALayerinstance is referenced by$r0, the new X origin is in$r2, the new Y origin is in$r3, and the new size is*(CGSize *)$sp: