Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
On Feb 06, 2017, at 02:37 PM, Ken Thomases wrote: What is your cell view? An NSTableCellView with an NSTextField as a descendant view? An NSTextField directly? The default you get when you create a new table, NSTableCellView containing an NSTextField, which contains an NSTextFieldCell (and the default NSTextFieldCell as a sibling to the NSTextField). Are you also using bindings for the text field's value? How is that binding configured? Yes, the NSTextField's Value is bound to Table Cell View using Model Key Path objectValue.EmailAddress. These are on: Allows Editing Multiple Values Selection Conditionally Sets Editable Raises for Not Applicable Keys Going up the chain, the column has no bindings set. The table's Content is bound to an Array Controller, Controller Key arrangedObjects. That Array Controller's Content Array is bound to Shared User Defaults Controller, Controller Key values, Model Key Path EUGEmailAddresses (an array of dicts), Mode Class, Class Name NSMutableDictionary, Prepares Content, Editable, a single Key named EmailAddress. Sent from iCloud's ridiculous UI, so, sorry about the formatting ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
On Feb 6, 2017, at 8:43 AM, Steve Mills wrote: > > The problem is that when I edit values in the table, they only seem to get > written to the defaults if I add a new item after editing an existing item. > > 1. Run app. > 2. Edit existing row value. > 3. Add new row and edit it. > Result: Edited row is changed, new row has only default value instead of > edited value. > > Any ideas? What is your cell view? An NSTableCellView with an NSTextField as a descendant view? An NSTextField directly? Are you also using bindings for the text field's value? How is that binding configured? Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
On Feb 06, 2017, at 10:30 AM, Keary Suska wrote: Warning: the following explanation assumes a scenario that you don’t explicitly describe, namely that you are editing an array-type defaults value. This is a known “issue”, if you want to call it that. As I understand it, the problem is that NSUserDefaultsController cannot "deep-observe” array-type defaults. I.e., it can watch the array itself for changes but not individual array elements because there is no clear key path to a specific array element. That is why you see changes when you alter the array itself (by adding/removing array elements), but not changes to the values of individual array elements. So, this is a limitation to the implementation of KVC/KVO, rather than any specific issue with NSUserDefaultsController. The only way to handle this situation, IMHO, is to have some intermediary or user-driven event (like a “commit” button) that “tricks” the defaults controller into thinking the entire array has changed when you need to it see changes to individual elements. I don't think that's the issue. We have other tables that are able to change existing values within arrays in prefs, although they are cell based instead of view based. To aid debugging, I've connected an action method to the NSTextField used in the NSTableCellView to be called when editing is ended. If I log the pref at that time, it's still the old value. So the field editor is not even writing the new value to the prefs. The only way I've been able to make this work is by handling controlTextDidEndEditing: in the table's delegate and manually setting the value in prefs, even though the value is coming from the arrayController.content, which is what's bound to the pref in the first place. Sent from iCloud's ridiculous UI, so, sorry about the formatting ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
> On Feb 6, 2017, at 7:43 AM, Steve Mills wrote: > > (Has cocoa-dev been down for days or what?) > > Why is it that most times when I implement a table, it can waste hours of my > time? > > So I think I have everything set up like it should be. I'll just jump right > to the bug and then we can work back. The problem is that when I edit values > in the table, they only seem to get written to the defaults if I add a new > item after editing an existing item. > > 1. Run app. > 2. Edit existing row value. > 3. Add new row and edit it. > Result: Edited row is changed, new row has only default value instead of > edited value. > > Any ideas? Warning: the following explanation assumes a scenario that you don’t explicitly describe, namely that you are editing an array-type defaults value. This is a known “issue”, if you want to call it that. As I understand it, the problem is that NSUserDefaultsController cannot "deep-observe” array-type defaults. I.e., it can watch the array itself for changes but not individual array elements because there is no clear key path to a specific array element. That is why you see changes when you alter the array itself (by adding/removing array elements), but not changes to the values of individual array elements. So, this is a limitation to the implementation of KVC/KVO, rather than any specific issue with NSUserDefaultsController. The only way to handle this situation, IMHO, is to have some intermediary or user-driven event (like a “commit” button) that “tricks” the defaults controller into thinking the entire array has changed when you need to it see changes to individual elements. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
(Has cocoa-dev been down for days or what?) Why is it that most times when I implement a table, it can waste hours of my time? So I think I have everything set up like it should be. I'll just jump right to the bug and then we can work back. The problem is that when I edit values in the table, they only seem to get written to the defaults if I add a new item after editing an existing item. 1. Run app. 2. Edit existing row value. 3. Add new row and edit it. Result: Edited row is changed, new row has only default value instead of edited value. Any ideas? Sent from iCloud's ridiculous UI, so, sorry about the formatting ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com