Can't programmatically bind NSImageView in view-based NSTablveView cellView

118 views Asked by At

I have a view-based NSTableView which is a single column with a custom CellView containing about a dozen text fields and a single NSImageView.

-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
    ComboTableCellView* view = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:nil];

    // I bind the text fields with:

    [[view nameView] bind:NSValueBinding toObject:view withKeyPath:@"objectValue.name" options:nil];

    // I bind the NSImageView with:

    NSMutableDictionary* statusOptions = [[[NSMutableDictionary alloc] initWithCapacity:0] autorelease];
    [options setObject:kStatusIconTransformerName forKey:NSValueTransformerNameBindingOption];
    [[view statusView] bind:NSValueBinding toObject:view withKeyPath:@"objectValue.status" options:statusOptions];

    return (view);
}

My transformer takes "status" which is an NSNumber and returns an NSImage because status will be a number from 1 to 4. This works in a cell based NSTableView with an NSImage column.

However, in my view-based NSTableView I get:

Cannot remove an observer (NSAutounbinderObservance 0x600000028ac0) for the key path "objectValue.status" from (ComboTableCellView 0x6180001e3e00), most likely because the value for the key "objectValue" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the ComboTableCellView class.

How can I correctly bind an NSImageView that is within a reuseable view used as the row/cellview in a view-based NStableView?

0

There are 0 answers