I have a very simple project containing an NSTableView with 3 columns and buttons for adding new row, removing row and saving the data.
For the purposes of this project I want to save the values into the NSUserDefaults db AND to do all this with no coding, so the IB connections and properties are as follows:
Added Array Controller object via IB. Its Controller content is bound to Shared Users Defaults Controller (Controller Key:values, Model Key Path: myvalues), Handles Content as Compound Value checked.
Added the table view set to have 3 columns and set as view-based.
For the table view itself, its Content is bound to Array Controller (Controller Key arrangedObjects) and its Selection Indexes are bound to Array Controller (Controller Key selectionIndexes)
For each column of the table, the Table View Cell item (third in chain) Value is bound to Table Cell View (Controller Key empty, Model Key Path set to objectValue.xxxx where xxxx is an arbitrary name string for the column); also the Behavior attribute is set to "editable".
The add row and remove row buttons sent actions are connected to the Array Controller add and remove methods and the Save button sent action is linked to the Shared User Defaults save method.
When I run the project I can initially do "add", enter the values for the columns, click on Save, end execution and when I re-run it the data is shown. However, if I then try to change any of that data, the changes won’t be kept. If I add additional rows, and enter data that data is not kept (the rows will be there, just empty). Removing rows works as expected. (NOTE: also if I added several rows on the initial execution, only the first would have data on subsequent executions)
My question is: Why won’t data changes (after the first) work? It seems like there’s a missing layer somewhere.
I created a second project, very similar to first, but specified cell-based table rather than view-based; also the bindings are simpler with NO bindings for table-view but just directly bind table cells Value to Array Controller. This project works perfectly. Cell data can be edited, new row data entered, etc.
Any help would be appreciated