Can Poyrazoğlu
Can Poyrazoğlu

Reputation: 34780

How to create a "break-able" symbol for Xcode for use in symbolic breakpoint debugging

I know how to set a symbolic breakpoint. I was wondering how can I make one myself? I will have a function, and if something is not asserted, I don't want an assertion failure, but a log message saying something like "Number is negative, break on XXX to debug" just like layout constraint satisfaction problems. When user adds symbolic breakpoint at XXX, I want to break when assertion fails. How do I construct that "XXX"?

Upvotes: 0

Views: 76

Answers (1)

Walt Sellers
Walt Sellers

Reputation: 3939

Make a function or method with a fairly unique name (to prevent name collisions) which is where the error you mentioned is logged. Then that will be the symbol to set the breakpoint on.

- (void)myAPI_Range_Error {
    NSLog( @"%@", @"Number is negative, break on myAPI_Range_Error to debug" );
}

- (void)myAPI_SomeMethod {
    if (self.startNumber < 0 )
        [self myAPI_Range_Error];
}

Upvotes: 1

Related Questions