iOS Dev Nugget 178 Breakpoint Actions for Logging


Need to run a code review on your codebase? Hire me

The debugger is a very useful tool. But very often, I turn to the old trusty NSLog (and friends) for debugging. If you are trying to narrow down an issue using logging, the add NSLog statements, recompile, run, tap that button to replicate the issue, check output cycle can be inefficient. This is where breakpoints are incredibly useful.

  1. Click at the gutter in Xcode editor on the line of code where you want to perform the logging.
  2. Ctrl-click the breakpoint and choose Edit Breakpoint
  3. Click Add Action
  4. Choose Log Message
  5. Type the message to log in the Message textbox
  6. Check Automatically continue after evaluating actions

Trigger the issue. No re-compilation required. Yay!

There's a couple of useful options in the dialog such as making it speak out the message instead of logging.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues