Where is the expression window in Xcode 4?

20,751

Solution 1

I don't know that there is an option to create a watch expression directly from Xcode 4's code window. If there's something in the code window you'll want to add an expression watch for, I think you'll have to copy that code to the clipboard.

Then while debugging, make sure the debug area is being shown. It is the bottom center view in Xcode. You can show this area by clicking the appropriate view icon from the debug view.

Show Xcode 4's Debug Area

Then in the lower left of the debug area, you have your watch list. You can add an expression to this list by right-clicking and selecting Add Expression:

Right-click to add an expression http://blog.roughfalls.com/non-wp/img/xcode4_addexpression.png

After you select this option, a dialog appears. You can paste the expression that you copied to the clipboard into this dialog, and click "Add." Watch expressions are denoted in the list with a small "E" icon to their left.

Solution 2

Just a note: I had a problem with expressions that they didn't get evaluated (Expression in Xcode 4.3.2 Debug area not evaluated).

To make it working, I had to include also the result type of the expression (e.g. (NSString *)[tag name]).

enter image description here

Share:
20,751

Related videos on Youtube

jcpennypincher
Author by

jcpennypincher

I am a Lead iOS Developer in Vancouver, Canada. I have 9 years of experience in iOS development. I use Swift / Objective-C / C / C++ and I have also spent considerable time with Bash, Ruby, Perl, Python. I have advanced knowledge of application and systems programming, design patterns, algorithms, and networking. I have contributed to over 1000 apps on the Apple Store in a multitude of different industries including children's medicine, children's educational software for autism, hospitality, systems engineering, publishing, and manufacturing. I continue to pursue professional development in cloud computing, context aware computing, software architecture, and systems engineering.

Updated on July 09, 2022

Comments

  • jcpennypincher
    jcpennypincher almost 2 years

    How can I add an expression to watch in Xcode 4?

    This should be very obvious, but it is not. It does not seem to be down any menu or available on a contextual click. It would be nice if I could highlight a variable or expression and then "Add to watch" or "Add expression".

  • jcpennypincher
    jcpennypincher about 13 years
    Thanks for such a great response Andrew.!
  • erikprice
    erikprice over 12 years
    The image links in your answer have rotted.
  • Andrew Brown
    Andrew Brown over 12 years
    @erikprice - finally fixed this, thanks again for calling it to my attention.
  • RLT
    RLT about 12 years
    How do we remove watch from variable?
  • Tony
    Tony almost 12 years
    I can't seem to figure out how to remove the expression watch once it has been added. Does anyone have a suggestion?
  • Raffi Khatchadourian
    Raffi Khatchadourian over 11 years
    What does the "Watch" option do in that screenshot? How does it differ from "Add Expression..."?
  • ericsoco
    ericsoco about 11 years
    @Tony and xus, to delete the expression, right-click it and select "Delete Expression".

Related