我已将 NSSwitchCells 列绑定到 NSArrayController。值 ON/OFF 正确显示,但是当我单击它时,值不会改变。开关框提供点击的视觉反馈,但值保持不变(选中或未选中)。
我已经尝试了各种绑定选项。
NSDictionary *bindingOptions = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:1], NSContinuouslyUpdatesValueBindingOption,
[NSNumber numberWithInteger:1], NSRaisesForNotApplicableKeysBindingOption,
[NSNumber numberWithInteger:1], NSConditionallySetsEditableBindingOption,
[NSNumber numberWithInteger:1], NSValidatesImmediatelyBindingOption,
nil];
[tableColumn bind:@"value" toObject:currentItemsArrayController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", editedColumnmetadata.columnBindingKeyPath] options:bindingOptions];
[(NSButtonCell*)cell setButtonType:NSSwitchButton];
[cell setTitle:@""];
[tableColumn setDataCell:cell];
谢谢
更新:(绑定到单元格?)
//[tableColumn bind:@"value" toObject:currentItemsArrayController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", editedColumnmetadata.columnBindingKeyPath] options:bindingOptions];
[cell bind:@"objectValue" toObject:currentItemsArrayController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", editedColumnmetadata.columnBindingKeyPath] options:bindingOptions];