Objective c NSSwitchCell不';单击后不更改值
我已将NSSwitchCells列绑定到NSArrayController。打开/关闭的值显示正确,但是当我单击它时,该值不会更改。开关框提供单击的视觉反馈,但值保持不变(选中或未选中) 我尝试过各种绑定选项Objective c NSSwitchCell不';单击后不更改值,objective-c,macos,cocoa,Objective C,Macos,Cocoa,我已将NSSwitchCells列绑定到NSArrayController。打开/关闭的值显示正确,但是当我单击它时,该值不会更改。开关框提供单击的视觉反馈,但值保持不变(选中或未选中) 我尝试过各种绑定选项 NSDictionary *bindingOptions = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWith
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];
谢谢
更新:(绑定到单元格?)
您必须遵循以下步骤,如果需要更多详细信息,请告知我:- 首先,您必须将复选框单元格的列绑定到绑定检查器内部的arraycontroller,如下面的屏幕截图所示 数组控制器中的第二件事是,如果要更新复选框单元格的值,请将此操作方法写在下面,并仅将此操作方法连接到复选框单元格的表列
-(IBAction)clickChekBoxcell:(id)sender
{
NSInteger chkCell=[sender integerValue];
NSNumber *num=[NSNumber numberWithInteger:chkCell];
NSMutableDictionary *dict=[NSMutableDictionary dictionary];
for(dict in [arrCont arrangedObjects])
{
[dict setObject:num forKey:@"checkYesNo"];
}
[arrCont rearrangeObjects];
}
你把表格列复选框单元格绑定到arraycontroller了吗?@hussainShabbir我没有。我应该怎样确切地装订它?我已将代码添加到我的问题中。如果我取消对line tableColumn的注释,按钮将被禁用,我将无法与它们交互。第二行,绑定到单元格,不会改变当前行为中的任何内容。
-(IBAction)clickChekBoxcell:(id)sender
{
NSInteger chkCell=[sender integerValue];
NSNumber *num=[NSNumber numberWithInteger:chkCell];
NSMutableDictionary *dict=[NSMutableDictionary dictionary];
for(dict in [arrCont arrangedObjects])
{
[dict setObject:num forKey:@"checkYesNo"];
}
[arrCont rearrangeObjects];
}