Categories
Development Objective-C Work Note

Work Note: Conditional Breakpoints in Xcode

If you’ve been developing for any period of time you’ll understand that the debugger is your friend. This tip is probably not new to a lot of folks, but I thought I’d share for anyone new to Xcode, Cocoa, and Objective-C development.

The Conditional Breakpoint

We’ve all set breakpoints in Xcode while debugging, but did you know you can set conditional breakpoints? Let’s say you’re processing a large quantity of data and you say to yourself “Man, I wish I could break right here when the value of this string is ‘labs'” Guess what, you can. Two easy steps

Step #1: Right click (Command-Click) on the breakpoint and select Edit Breakpoint…

Edit Breakpoint in Xcode

Step #2: In the popover type “(BOOL)[documentName isEqualToString:@”labs”]” into the Condition field.

Xcode Breakpoint Condition
That’s all you need to do! In this case the breakpoint will be skipped until documentName is “labs.”