如何使用NSTreeController和NSOutlineView观察项目的编辑

时间:2011-10-31 16:18:55

标签: objective-c nsoutlineview nstreecontroller

我使用NSOutlineView填充NSTreeController。树控制器管理NSMutableDictionary数组,其属性包括:NSString *nameand NSArray* children

如何在用户界面中更改name时收到通知?

1 个答案:

答案 0 :(得分:0)

只需将一个函数放入NSOutlineView

的委托中
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
    // for example that is checked that node text is not empty
    if ([[fieldEditor string] length] == 0)
    {
        return NO;
    }
    else
    {
        return YES;
    }
}