In MS visual studio we just right click add watch.
How does one do this in Xcode?
po
command in the Debug areaSet up a breakpoint on the relevant area of code, then when the program stops at the breakpoint, enter commands in the Console in the Debug Area.
The relevant command is po
(print object) followed by the expression you want to evaluate.
If the Debug window is not visible in XCode, you can show it via the top menu:
'View' -> 'Debug Area' -> 'Activate Console'
(XCode v8.x)
To evaluate an expression like var1/var2
where var1
and var2
are both doubles, enter the following in the Console:
po var1/var2
The Console will return something like:
(double) $2 = 3.085 [no Objective-C description available]
You can also return a particular property of an object currently used in the code at that breakpoint:
po [bankInfo city]
And it will return something like:
(id) $4 = 0x000069e8 Testville
Note though that the Console doesn't seem to like the dot notation and prefers the square brackets when applicable. For example, this returns an error for me:
po bankInfo.city
I hope this is what you've been looking for.