Digging Deeper into Breakpoints
By default, a breakpoint does one thing: it breaks! That is to say, it halts execution when reached, and lets you inspect the program state.
While it’s not immediately obvious, breakpoints can do a lot more than this. If you control-click or right-click a breakpoint in the gutter, you can delete it, disable/reenable it, or edit it. Editing a breakpoint shows a pop-over window with a bunch of interesting options.
The first thing you can do in the editing pop-over is to assign a condition. If a condition is set, the breakpoint will only pause if the condition is met. For example, if the calculatePrimes(to:) method were misbehaving for large values of max, you could set the condition to only break for max >= 1000000 ...
Get Xcode Treasures now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.