tags:

views:

31

answers:

1

Hello. I hope this question is some what self explanatory.

This works, returns YES and NO: note the NSLog()'s

- (BOOL)dateTestCourse:(NSDictionary *)listing {
    BOOL result =  ([self exammpleTest] == 0) ? YES : NO;
    if (result) {
        NSLog(@"Passes Test");
        return YES;
    }
    NSLog(@"Failed Test");
    return NO;

}

But below always return YES? Only difference is no NSLog();

- (BOOL)dateTestCourse:(NSDictionary *)listing {
    BOOL result =  ([self exammpleTest] == 0) ? YES : NO;
    if (result) {
        // NSLog(@"Passes Test");
        return YES;

    }
    // NSLog(@"Failed Test");
    return NO;

}

Is this something to do with C? I have no idea? I might expect it always to return NO (if I shouldn't be breaking in the conditional), but surely that would return YES.

I know I should be returning result in the above examples, but I'm curious to know why.

+1  A: 

These two blocks of code should be running the same. Are you perhaps doing a find/replace all on NSLog? That could be causing issues elsewhere, say with the exammpleTest(sic) method.

Also, the ternary operator on the second line is redundant, consider reducing that line to:

BOOL result =  ([self exammpleTest] == 0);
jenningj