> On May 5, 2016, at 7:44 AM, Jerry Krinock <je...@ieee.org> wrote:
> 
> In an OS X app, I wanted to bind a table of objects, each represented by a 
> dictionary, to an array of dictionaries in user defaults.
> 
> So I bound the Content Array of the array controller to the 'values' of the 
> shared user defaults controller with an arbitrary key path, which pleasantly 
> became the key to the array in the user defaults.  I set "Handles Content as 
> Compound Values” to ON.

Is this a single or multi-level keypath? IIRC the issues Quincy is referring to 
are common in a multiple-object keypath, especially for defaults as 
NSUserDefaultsController uses some internal trickery to edit the immutable 
collections maintained by NSUserDefaults.

> Result: The table is populated as expected from user defaults when its window 
> opens, and all works and persists as expected if user adds or deletes an 
> object (row).  But changes to object attributes are persisted only for new 
> objects, and only if user adds *another* object before quitting.

I cannot replicate this behavior with a straightforward approach. Can you 
create a reduction that replicates the behavior?

> In the array controller's content, the object attribute is always changed as 
> expected.  So, the problem is the binding of the array controller content to 
> user defaults, and I think the explanation is that, as always, KVO is 
> “shallow”.  Observing an array does not observe changes to its elements.

This is curious—how do you know that the attribute is being changed as 
expected? Is it that it shows in the UI, but is not persisted? Have you changed 
the default value of -[NSUserDefaultsController  appliesImmediately]?

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

Reply via email to