Reputation: 29518
I'm trying to figure out how to use the log or debug commands in adding actions to a breakpoint. I can't seem to figure it out. For something like this:
double currentZoom = [self getZoomScale];
How do I print out the currentZoom? I tried using log as my action, and then doing
currentZoom: @(double)currentZoom@ // this didn't work
currentZoom: @(double)[self getZoomScale]@ // also didn't work
Can someone help me out with this and any other info I may need to log information with breakpoints?
And also a simple example for po
an object. Does po
always po
the description (as in you have to have overridden the description method? Thanks.
Upvotes: 2
Views: 1069
Reputation: 8143
You can make the breakpoint execute debugger commands.
Open the edit breakpoint pane:
.
Then type a debugger command (selecting "Automatically continue after evaluating" is advised).
To insert some context around the automated debugger commands, you can add another debugger action of type "Log Message". The "Log Message" action is not capable of inspecting variables itself.
NSLog()
is probably easier to implement, but requires you to change the code you are debugging.
Upvotes: 1
Reputation: 7986
I do not know how to add actions to a breakpoint. (I am interested in seeing it in any other answers offered)
The gdb syntax for printing objects is
po objectName
The gdb syntax for printing C variables is
print (int) intNum
print (float) floatNum
Upvotes: 0
Reputation: 7082
If you want to print your double with NSLog, add the following line:
NSLog(@"%f", currentZoom);
Now, if you want to use the debugger console...
If you want to print currentZoom in the console, you don't need po. Plain p would be enough.This is, type
p currentZoom
and it's going to show you currentZoom's value. po is for objects. Let's say you wrap currentZoom in an NSNumber.
NSNumber currentZoomNumber = [NSNumber numberWithDouble:currentZoom];
Then, to print the value, you would have to do
po currentZoomNumber
Like i said, po is to print objects, it means print object. So you can use it to print any type of object, from NSStrings and NSNumbers to NSDictionaries and NSManagedObjects.
Upvotes: 3