At one point or another, I’m sure we’ve all used a
Until this week, that was my usual approach too. But then I came across a very interesting tip. You can do the exact same thing in Xcode without changing your code at all. Set a break point, control-click it, and then click “Edit Breakpoint…”. You can add your debug message straight into the breakpoint like this:
It’s a nice way to clean up your code, and the ability to easily toggle the breakpoints is handy too. Note that “breakpoint” is a bit of a misnomer in this case: because we clicked that checkbox, program execution isn’t interrupted (i.e., there’s no break). Nice!
I picked this up from Rehat Kathuria’s article, “Xcode, supercharged“. Some good tips there, and this one in particular really jumped out at me.