Tagged: objective-c

XCode breakpoint tip

Use breakpoints to replace NSLog statements while debugging your code.

Screen Shot 2013-05-09 at 9.08.49 AM

Steps:

1. Add a break point.
2. Hold option + command and click the break point to edit it.
3. Tap the add action button.
3. Add an action or expression like below.

LLDB (debugger) action
[c collapse=”False”]
po myVar
[/c]

Expression
[c collapse=”False”]
expr (void)NSLog(@"myVar = %d", myVar)
[/c]

Select “Automatically continue after evaluating” to continue without stopping the code.

Advantages:

1. Easier to manage: e.g. you can view all the breakpoint and more in the breakpoint navigator (second button from the right in the navigator pane).

2. You can edit the actions or expressions, or add breakpoints while the code is running.

Source: 2012 WWDC video: Debugging in XCode. Much more information in this video.