2

What do I need to do to have variables display their values in XCode?

I don't have it in Auto pane, and it also does not show when I hover over it. Why is that?

I can go Add Expression and sometimes it will display it correctly, and I can also do NSLog and log it, but this seems really ridiculous in the year of 2013.

I am using XCode 4.6. Am I doing something wrong, or this basic functionality just does not exist?

0

2 Answers 2

3

You can use the local variables section in the content pane to view variable values while debugging:

enter image description here

You can use shift + command + Y to toggle the above pane.

For more information regarding debugging in xCode, check out the following link.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the answer, but it's a lot of manual work and sometimes I have to drill down a lot to get to the variable, and then it shows the WRONG VALUE! I don't get this. It is as if it does not show an instance value, but the one at the initialization. And a tooltip with var value does not exists, seems to me. I will check the link you sent me and see if anything in the Apple's documentation, thanks.
@user1405583 Really? hmm that's weird :/ I've never received a wrong value from it I don't think.. I tend to just set breakpoints at certain points and have this window up to see how the values check as I step through
Not really, I searched Apple forums and this seems to be a well known bug they are fighting for many versions, and is stil there, occuring regularely. Thanks.
@user1405583 Could you link me to a post about it? Sounds quite interesting now, anyway hope the answer helped a bit.
1

In the console use the command 'po' (stands for print object) e.g. po [self myVariable]

This will give you more information than this semi-useless variable tree in the content pane.

hints:
1) Make sure your build configuration is set to Debug, or you can't debug local variables.
2) Sometimes you need to debug structs and primitives, in this case use 'p' instead of 'po'
3) you can use dot notation (po self.myVariable), but for some data types this doesn't seem to work. I believe it depends on your xcode version

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.