Search code examples
xcodedebuggingconditional-breakpoint

Xcode breakpoints: break on string compare


I can do conditional breaks in Xcode using string compare?

something like: theLabel.text.range(of:"4") != nil


Solution

  • You are describing a conditional breakpoint. Double-click the breakpoint marker and enter the expression you want evaluated. You will break only if the expression is true.

    Be sure to test your expression in code, first, to make sure it is valid. In your case, you need to remember that text is an Optional:

    enter image description here