In MS visual studio we just right click add watch.
How does one do this in Xcode?
Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope. This command takes 'raw' input (no need to quote stuff). -G <gdb-format> ( --gdb-format <gdb-format> ) Specify a format using a GDB format specifier string.
Execute a function at design timeOn the Debug menu, choose Windows > Immediate.
The Watch Window. The Watch Window allows you to see value of variables and expressions while debugging. It's kind of like the DataTip you get when hovering over a variable, except that you can write any expression you want. It's available from Debug | Windows | Watch | Watch 1 or Ctrl + Alt + W + 1.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With