I am very lost in Xcode 4. Watching a simple variable is a nightmare. I do not figure out how to just "watch a variable value". It was easier in Xcode 3...
I have the following piece of code:
if (labelEast.center.x > (east_oldPosition.x + 50) )
NSLog(@"Time to switch to previous exercise !");
else if (labelEast.center.x < (east_oldPosition.x - 50) )
NSLog(@"Time to switch to next exercise !");
After setting a breakpoint, I am just trying to watch labelEast.center.x
(labelEast
is a UILabel
object). Since I could not find a watch item in a Xcode 4 menu, I am trying to use gdb. I am used to print variable/object values with po
(print object). But now, I cannot display labelEast
center
property because it is inherited from a mother class.
(gdb) po labelEast.center
There is no member named center.
I do not understand why gdb says this whereas the code works fine and sees the property.
Thus I have 2 questions:
Many thanks, Franz
Unfortunately, I tried it but got this:
po [labelSouth center]
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x1a000356 0x343c7d06 in objc_msgSend_stret () The program being debugged was signaled while in a function called from GDB. GDB remains in the frame where the signal was received. To change this behavior use "set unwindonsignal on" Evaluation of the expression containing the function (objc_msgSend) will be abandoned.
And when I try:
(gdb) print labelSouth.center
There is no member named center.
I really suspect there is no access to center property in UILabel
. But how can me code run ???
I've hit this thing a few times myself just to remember "oh, that's right, gdb doesn't support dot notation so I have to use getter". Then just do:
(gdb) po [myObject someProperty]
and all is well with the world again. Also rereading your question I see that you're requesting a non object to be printed, hence you have to give gdb a hint of what type of property you want to print:
(gdb) p (CGRect)[myView frame]
(gdb) p (CGPoint)[myView center]
and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With