How to set a conditional breakpoint in Xcode based on an object string property?

后端 未结 5 1101
鱼传尺愫
鱼传尺愫 2020-12-02 05:21

I\'m looking to be able to have the debugger break when it reaches a particular string match. As an example, I might have something like this:

Foo myObj = [s         


        
5条回答
  •  渐次进展
    2020-12-02 05:43

    At times when working with Frameworks (debug builds) and need to put a breakpoint in certain file/location that is hard to navigate or isn't exposed publically in framework under development. One option is to write a helper class to trigger conditional breakpoints & make step-in/step-out easier.

    - (void)invokeFrameworkMethod {
        ...
        [DebugConditionalBreakPointHelper breakPointCondition:YES comment:@"from invokeFrameworkMethod."];
        ...
    }
    

    Header declaration in framework under development.

    #import 
    
    @interface DebugConditionalBreakPointHelper : NSObject
    + (void)breakPointCondition:(BOOL)enabled comment:(NSString *)comment;
    @end
    

    And implementation file:

    #import "DebugConditionalBreakPointHelper.h"
    
    @implementation DebugConditionalBreakPointHelper
    + (void)breakPointCondition:(BOOL)enabled comment:(NSString *)comment {
        if (enabled)
        {
            NSLog(@"Triggerred Conditional Break Point. Comment: %@");
        }
    }
    @end
    

提交回复
热议问题