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: Peter <email@hidden>
- Date: Tue, 07 Jan 2014 23:27:27 +0100
Am 07.01.2014 um 23:16 schrieb Keary Suska <email@hidden>:
> 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).
Yes, I did, but no, sadly it doesn’t.
> 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.
OK, thanks for the pointers. This confirms my suspicion that (a) there is no simple way to do it (as in cell based tables) and (b) that view based tables, despite some obvious advantages, are not to be considered to be the Holy Grail of Table Making - as Apple wants to make us believe.
BTW: The delegate methods I had intended to use in my outline above turned all out to be disabled for view based table views.
Thanks a lot for your time and comments!
> 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