Re: Set up an editable view based NSTableView programmatically - how to?
Re: Set up an editable view based NSTableView programmatically - how to?
- Subject: Re: Set up an editable view based NSTableView programmatically - how to?
- From: Keary Suska <email@hidden>
- Date: Tue, 07 Jan 2014 15:16:09 -0700
On Jan 7, 2014, at 1:38 PM, Peter wrote:
> Thank you for your comment.
>
> Did you really manage to create *editable* view-based table views with data sources?
Yes.
> Then I am curious to know how you managed to make them editable.
The issue here is simply how to communicate edits to your model object, which I will assume you mean by "making editable".
> A data source method channeling data from the table view to the data source is nowhere to be seen.
>
> - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
>
> does not seem to be called.
No, you can't use this method with view-based table views. And it makes sense, as the table view wouldn't how how to apply edits to the model object since it could be arbitrarily complex.
> I have a view based table view working with a data source. But it is not (yet) editable.
>
> The only thing I can imagine is to catch textDidEndEditing in a delegate from the field editor and get the value via editedRow and editedColumn or something similar.
> But this is rather awkward.
>
> I wonder why there is nothing relevant in the docs, no example on the web...
Did you look at TableViewPlayGround sample code? It might have editable examples (I don't recall). There are a number of ways you can do this. My case is a bit specific and complex (every cell in in my table is different), but my basic approach was to designate a set of NSViewControllers that are set as the owners of the views in -tableView:viewForTableColumn:row: (as well as in IB), and in the view I have an NSObjectController bound to the view controller's representedObject, and the editable fields bound to it in turn.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden