Date
Nov. 25th, 2024
 
2024年 10月 25日

Post: Easier debugging using breakpoints with actions

Easier debugging using breakpoints with actions

Published 12:02 Feb 02, 2014.

Created by @ezra. Categorized in #Programming, and tagged as #iOS.

Source format: Markdown

Table of Content

If you debug solely through NSLog you are missing the better insight the debugger can provide you. Also, it is easy to forget all those logging functions, ship them into production and, depending on the industry, even introduce security risks.

On the other hand, if you are using only basic breakpoints you might find yourself typing po <object> just too often.

This is where breakpoint actions come handy: you can configure breakpoints that execute debugger commands like printing variables. To do so:

  1. Right click on any pointer and select Edit Breakpoint....

  2. Then, select Debugger Command from the Action menu and type a command to some variable in the scope of the selected breakpoint. For example: po sender to print the debug description of an object identified as 'sender' or p selectedSegment to print the value of an atomic variable named 'selectedSegment'. If you feel in a verbose mood and need to output lots of stuff, you can click the '+' button and add more commands with more prints.

  3. By selecting the option Automatically continue after evaluating, the breakpoint doesn't stop the execution of the program and behaves like an elegant version of NSLog that keeps your code clean.

Breakpoint Actions

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询