I have view based NSTableView
with two columns. Instead of default NSTextField
s I have inserted NSTextView
s. For populating the table I am using the array of tuples of two strings. After I change the text in the NSTextView
s I want to save back all changes from all rows and columns to the source array by clicking the button. I need to know each row and NSTextView
s to get the strings for the array. How to do this ? First problem is that I cannot even make the tags for particular NSTextView
s, they are inactive in Attributes Inspector (for NSTextField
s tags are active).
Asked
Active
Viewed 218 times
0

VYT
- 1,071
- 19
- 35
-
Actually the view (table view) is supposed to be the "mirror" of the model (data source array). Especially OSX with its `Cocoa Bindings` capability makes it quite easy to keep view and model in sync without getting data back from the view. – vadian Apr 17 '16 at 10:57
-
@vadian There is a way how automatically to save the changes in the row selected for editing - http://stackoverflow.com/questions/28281045/view-based-nstableview-editing. But, first it is only for the case with NSTextField, not NSTextView, and second it is automatic. I would like to have the saving by clicking the button. – VYT Apr 17 '16 at 11:05
-
it's also possible with NSTextView. To have a "draft" state connect the text view to a "draft" variable and save the contents to another when the button is clicked. And to identify the row of that button is very easy in a view based table view. Reading data from the view to the model is the last option if you have no other choice. – vadian Apr 17 '16 at 11:11