View selector return value when debugging in Xcode
I am running an iPhone development tutorial and I have a strange error that I am investigating with the debugger. I have the following code that checks if an object is within bounds. I'm trying to figure out that the value of ball.center.x is at a specific point, but since the center is the property access selector, I don't get the value when I find it in the Xcode debugger.
if (ball.center.x > self.view.bounds.size.width || ball.center.x < 0) {
ballVelocity.x = -ballVelocity.x;
}
Is there a way to do this? I think I just need to be missing something. I'm guessing that I could update the code to assign a value to a variable that I could observe in the debugger, but that seems like a sloppy work around a common problem.
Thank!
source to share
There is an even easier way to do this than using the gdb console. From the main menu select:
Run -> Variables View -> View in expression window
And in the expression box text box enter:
(CGPoint)[ball center]
The main problem with expression windows displaying an "out of scope" error is almost never knowing the return type of a function (or method), so it doesn't know how to represent the return variable. Apple is letting us know what to do, these are the cases here in the Tips for Using the Expressions Window.
source to share