Is there a way to watch variables without using breakpoints in Xcode 4?

I’m sure I already know the answer, but thought that I would ask anyway. I am very tired of having to create logs and breakpoints to make sure my variables are where I want them to be at a specific point.

Does anyone know a way to view a variable at startup without breakpoints / logs?

Thanks!

+4
source share
2 answers

If you want to make sure that your variables must be defined in a certain way at a certain point, for which statements ( NSAssert() for example).

If you just want to know when a variable changes, use a watchpoint, not a breakpoint. (Click on the variable in the debugger and select "Watch.")

If you want to check a variable at a specific point and break it up only if it is “something in particular”, use a conditional breakpoint. Right-click on the breakpoint in xcode and select Change Breakpoint. You can also use this to break them up so often (for example, after 100 fires).

If you just want to know when the line of code is reached, but does not stop there, use the "Sound" action in the "Edit breakpoint" window and then "Continue automatically after evaluating actions". I use this quite a lot in performance. When I hear this starts to buzz, I know that I found the code in the code.

Did you have anything else in mind?

+6
source

Following Rob Napir’s recommendations, you can also edit the breakpoint to register the values ​​that concern you, and then continue, for example:

Image showing a logging breakpoint.

As you can see, I set this breakpoint to register the value of the [marker center] expression. GDB often needs help to find out what the final type of expression is, so I had to add a cast (CGPoint) . This is obviously a little more than just a click in the left column to set a normal old breakpoint, but it is probably less than inserting NSLog() instructions in your code, and you can do this in the middle of a debugging session - no need recompile or even restart the application.

+4
source

Source: https://habr.com/ru/post/1385042/


All Articles