Setting conditional breakpoint on an argument of type NSString

I have a method that gets called back:

- (NSDictionary *)attributesOfItemAtPath:(NSString *)path { ... }


I'm using xcode breakpoint and setting the condition [path isEqualToString:@"/abc"], but this breaks regardless of the value in path. How do I ensure that it only breaks when path is "/abc"?

Replies

This is working for me. Here’s what I did:

  1. I created a Mac app with the code shown below.

  2. I set a breakpoint on line 2 with the condition shown below.

  3. I ran the app and clicked my Test button.

  4. It printed the output shown below and then stopped at my breakpoint with

    path
    set to
    /System
    . Thus, the breakpoint ignored the first call and stopped on the second.

This is Xcode 7.2.1 on OS X 10.11.3.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
// From step 1:

- (void)testMethod:(NSString *)path {
    NSLog(@"%@", [[NSFileManager defaultManager] attributesOfItemAtPath:path error:NULL]);
}

- (IBAction)testAction:(id)sender {
    #pragma unused(sender)
    [self testMethod:@"/Applications"];
    [self testMethod:@"/System"];
}

// From step 2:

[path isEqualToString:@"/System"]

// From step 4:

… Test[…] {
    …
    NSFileGroupOwnerAccountName = admin;
    NSFileOwnerAccountID = 0;
    NSFileOwnerAccountName = root;
    …
}