1
votes

I have been trying unsuccessfully to edit and update items in a source List NSOutlineView, I’m not using a treecontroller but datasource and delegate.

My understanding is that outlineView:setObjectValue:forTableColumn:byItem datasource method applies to cell based outlineviews and doesn’t get called for view based.

The NSTableView has a similar datasource method tableView:setObjectValue:forTableColumn:row, however this time the documentation states that it is for cell based table and “Instead target/action is used for each item in the view cell.”

So, I’m not really sure how to do this, I tried textfield delegate methods below;

    - (void)controlTextDidBeginEditing:(NSNotification *)aNotification
{
    selectedRowList = [[self outlineView] selectedRow];
}

- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{

    NSManagedObject *selectedGoal = [[self outlineView] itemAtRow:selectedRowList];

    NSTableCellView *viewCell = [[self outlineView] makeViewWithIdentifier:@"DataCell" owner:self];

    [selectedGoal setValue:[[viewCell textField] stringValue] forKey:@"goalName"];

    [self updateOutlineView];
}

I can change the textfield value, however i can’t seem to get this value from the view. I think that the problem is the row is no longer selected once - (void)controlTextDidEndEditing:(NSNotification *)aNotification is executed.

Can someone point me in the right direction on how to best handle updating NSOutlineView items?

Thanks

1

1 Answers

2
votes

I had the same problem in my view based NSOutlineView, I used controlTextDidChange: to get updates:

- (void)controlTextDidChange:(NSNotification *)notification {
    NSTextField *textField = [notification object];
    NSTableRowView *parentRow = (NSTableRowView*)[[textField superview] superview];
    NSInteger row = [self.outlineView rowForView:parentRow];

    //..
}