'valueForKeyPath:' method in CPObjectController returns 'null marker' instead of nil #1987

Open
wants to merge 1 commit into
from

3 participants

@mrcarlberg
Cappuccino member

CPObjectController will return 'null marker' instead of nil when 'myAttribute' is nil in the following code:

[objectController valueForKeyPath:@"selection.myAttribute"]

The class '_CPControllerObjectProxy' returns the 'null marker' but it does not do it in Cocoa. I have a hard time figuring out how to solve this. I have only done the test case. Any help in doing this should be highly appreciated.

This might be related to #1986.

Here is a corresponding working test case for Objective-C:

- (void)testObjectControllerSelectionWithNil
{
    NSObjectController *controller = [[NSObjectController alloc] init];
    [controller setContent:@{@"name": @"Martin"}];
    STAssertEqualObjects([[controller selection] valueForKeyPath:@"name"], @"Martin", @"name equals 'Martin'");
    STAssertEqualObjects([[controller selection] valueForKeyPath:@"lastName"], nil, @"name equals 'nil'");
    STAssertEqualObjects([controller valueForKeyPath:@"selection.name"], @"Martin", @"selection.name equals 'Martin'");
    STAssertEqualObjects([controller valueForKeyPath:@"selection.lastName"], nil, @"selection.name equals 'nil'");
}
@cappbot

Milestone: Someday. Label: #new. What's next? A reviewer should examine this issue.

@ahankinson

For information, here is the Travis failure for this test case.

addFailure test=[CPObjectControllerTest testObjectControllerSelectionWithNil]: name equals 'nil' expected:<null> but was:<<NULL MARKER>>
Trace not implemented

-#new
+#accepted
+#needs-patch
+AppKit
+bug

@cappbot

Milestone: Someday. Labels: #accepted, #needs-patch, AppKit, bug. What's next? This issue needs a volunteer to write and submit code to address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment