Search code examples
xcodeios4variablesxcode4

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


I am pretty sure I know the answer already but thought I'd ask anyways. I'm about sick and tired of having to create Logs and Breakpoints just to make sure my variables are where I want them to be at a certain point.

Anyone know of a way to watch variable as they are running without breakpoints/logs?

Thanks!


Solution

  • If you want to ensure that your variables must be a certain way at a certain point, that's what assertions are for (NSAssert() for instance).

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

    If you want to check a variable at a certain point and break only if it's "something in particular," use a conditional breakpoint. Right click on the breakpoint in xcode and select "Edit breakpoint." You can also use this to only break every so often (such as after 100 fires).

    If you just want to know when a line of code is reached, but not stop there, use the action "Sound" on the Edit Breakpoint window and then "Automatically continue after evaluating actions." I use this quite a lot in performance work. When I hear it start buzzing, I know I've found a hotspot in the code.

    Did you have something else in mind?