5

For example, for some reason in initWithNibName:bundle: I can't see the value of self.view.bounds.size.width, have to stop the program and use NSLog. When I type self.view.bounds.size.width into the watch, I get "Enter expression" message on the right. When I type print self.view.bounds.size.width into the debug console, I get the following errors:

error: unsupported expression with unknown type
error: 1 errors parsing expression

Is there any way to see ALL the values I can see using NSLog?

EDIT: By @Abizern's suggestion tried p self.view.bounds.size.width and po self.view.bounds.size.width - same result.

Sergey
  • 47,222
  • 25
  • 87
  • 129

2 Answers2

4

try

p self.view.bounds.size.width

or alternatively:

po self.view 

p is a simple print which works for values

po is for print object which essentially give the same result as an NSLog

Abizern
  • 146,289
  • 39
  • 203
  • 257
  • Or even `p self.view.bounds` which works in recent versions of Xcode. – zaph Sep 17 '13 at 11:32
  • Tried both "po self.view.frame.bounds" and "p self.view.frame.bounds" - didn't work, still get the "unsupported expression with unknown type" error. – Sergey Sep 17 '13 at 11:40
  • Are you setting the breakpoint in the scope of these variables? – Abizern Sep 17 '13 at 11:40
  • Yes. To make sure I even set them right before and right after I use or assign this value and still get the same result. – Sergey Sep 17 '13 at 11:42
  • Worked, thanks! "print self.view" that I tried before just gave the pointer value, "po" output is much more valuable. Still, why can't I use "po self.view.frame.bounds"? – Sergey Sep 17 '13 at 12:41
  • because self.view.frame doesn't have a `bounds` attribute. you want self.view.frame, or self.view.bounds. – Abizern Sep 17 '13 at 12:55
  • 1
    Also, because bounds is a CGRect; a struct, not an object. If you want to use po with it try `po NSStringFromCGRect(self.view.bounds)` – Abizern Sep 17 '13 at 13:04
4

See this answer: https://stackoverflow.com/a/18923064/201828

Basically, bounds is not actually a member of UIView, but rather the layer. So just do:

p self.view.layer.bounds

This was driving me crazy, too :-(

Community
  • 1
  • 1
phatmann
  • 18,161
  • 7
  • 61
  • 51