各要素がチェックボックスになっているアウトラインビューがあります。いくつかのビジネスロジックによって提供されるように、これらのチェックボックスの初期状態を設定したいと思います。私はNSOutlineViewDelegateの適切な(私は願っています)メソッドでそれをやろうとしています:
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSButton *res = [outlineView makeViewWithIdentifier:@"checkbox" owner:self];
res.title = [item description];
if([item intValue] & 1)
res.state = NSOnState;
else
res.state = NSOffState;
return res;
}
すべてがほぼ問題なく、ボタンのタイトルが正しく変更されます。ただし、状態の変更は完全に無視されます。