views:

51

answers:

1

Hello there - I am trying to understand how to accomplish some basic debugging stuff with gdb

I want to check the length of this control (UILabel) if I type the following in the console I get nothing, what's the proper way to do it?

(gdb) po self.mylabel.frame.size.width
There is no member named frame.

or if I try without self:

(gdb) po mylabel.frame.size.width
There is no member named frame.

There must be a way, not obvious for sure. Visual Studio has such a fantastic debugger helpers in tracking the values of objects and co...

A: 

If you just type po myLabel, it will output the frame details. Of you can also use po NSStringFromCGRect(myLabel.frame). (See this link for some useful function along the lines of NSStringFromCGRect.)

Alternatively, width is a float, so you can use p (float) myLabel.frame.size.width.

In general, po is used to print the value of objects, while p is used for basic types.

Robot K
thank you for the very helpful tip. - Any idea why self is not printing anything? It should be an object, right?
amok
`po self` should work. Are you getting an error, or is it just doing nothing?
Robot K
it tells me "no symbols in frame" - the code runs fine and does the job.
amok
No idea. You might try asking in a new question.
Robot K