Where is the expression window in Xcode 4?
Asked Answered
T

4

43

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".

Tarlatan answered 12/4, 2011 at 8:37 Comment(2)
You're right. There should be. You cal also right click on the local variable window and click add expressions.Fourdrinier
Ups that's the answer shown. Sorry :)Fourdrinier
M
66

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.

Margitmargo answered 13/4, 2011 at 11:48 Comment(7)
Thanks for such a great response Andrew.!Tarlatan
The image links in your answer have rotted.Noahnoak
@Noahnoak - finally fixed this, thanks again for calling it to my attention.Margitmargo
How do we remove watch from variable?Rarebit
I can't seem to figure out how to remove the expression watch once it has been added. Does anyone have a suggestion?Polygamy
What does the "Watch" option do in that screenshot? How does it differ from "Add Expression..."?Teth
@Polygamy and xus, to delete the expression, right-click it and select "Delete Expression".Jennyjeno
B
7

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

Bowles answered 1/6, 2012 at 9:58 Comment(1)
I cant follow. I run using breakpoints, Add Expression = (CLLocation)self.userLocation but it just disappears after the first breakpoint.Dialyser
S
0

The image link is broken in the accepted answer, so here is an image to supplement it.

enter image description here

Right click the watch list in the debug area and choose "Add Expression..."

Saddletree answered 29/7, 2015 at 23:26 Comment(0)
F
0

For those looking for a Swift usage of Add Expression: Right click the Variables View in Debug Area. Then choose the Add Expression

enter image description here

Write your instanceName or instanceName.propertyName and press enter. It is that easy.

enter image description here

Furtado answered 19/6, 2016 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.