views:

54

answers:

3

When the debugger is stopped at a breakpoint, I can't find the frame of any of my UIViews in there.

Is it possible to do this?

EDIT: starting a bounty due to the lack of response. Just to be clear, what I am looking for is a way to see the frame without adding in extra debugging code.

Also, if the answer is "no you can't do it", bounty will go to the best explanation of why you can see some class members but not others.

A: 

Sometimes they are just out of scope by the time you get there.

Print them to the console:

NSLog('Frame: %d, %d, %d, %d', frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
Matt Williamson
Sure, there are lots of ways to do it if I code for it ahead of time.What I want is a way to do it that does not require advance coding. So that in the middle of a run, if I want to see the frame of view X, I can.
William Jockusch
+1  A: 

Yes, you can do it. While debugging, find the UIView of interest in the variable inspector. Control-click on it and select "Print Description to Console". For example, I did this on the _view ivar of a UIViewController and the following appeared in the console:

Printing description of _view:
<UIView: 0x25b460; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x26b740>>

Hilton Campbell
A: 

If you go to the debugger panel, you can type this in while you are at a breakpoint:

(gdb) print (CGRect) [self frame]
$1 = {
  origin = {
    x = 0, 
    y = 0
  }, 
  size = {
    width = 100, 
    height = 100
  }
}

When using the console debugger you can press the up arrow key to cycle through previous commands. Pressing return without entering a command repeats the last command.

Douglas