On Feb 06, 2017, at 10:30 AM, Keary Suska <[email protected]> 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 ([email protected])

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 [email protected]

Reply via email to