Thank you, Keary. > On 2016 May 05, at 13:47, Keary Suska <cocoa-...@esoteritech.com> wrote: > > >> On May 5, 2016, at 7:44 AM, Jerry Krinock <je...@ieee.org> wrote: >> >> 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?
single… Bind to = Shared User Default Controller Controller Key = values Model Key Path = persons Cocoa creates the “lower” levels (firstName and lastName in my demo) as dictionary keys automatically. > 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. Yes, this is not that. > I cannot replicate this behavior with a straightforward approach. Can you > create a reduction that replicates the behavior? https://github.com/jerrykrinock/ArrayDictionaryDefaultsDemo >> 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? By stopping execution and printing the array controller’s “content” in the debugger. I see the new value in the dictionary. > Is it that it shows in the UI, but is not persisted? Yes, when I type a new value into the table, it stays there. But it goes back to the old value upon relaunch. > Have you changed the default value of -[NSUserDefaultsController > appliesImmediately]? I just tried it. It did not help. I had already tried -[NSUserDefaults synchronize] after changing the value, which I presume does the same thing “manually”. * * * After reading Quincey’s reply, I had concluded that this is one of those cases where Cocoa Bindings requires additional “glue”, which defeats one of the two purposes of Cocoa Bindings. But it would be very cool if there were some configuration change that would be make this work in both directions. It seems like we’re really close. I’m accustomed to doing this kind of code-less binding to a Core Data model, wherein it “just works”. That’s not surprising, because of course Core Data knows the data model in great detail. It can observe everything. _______________________________________________ 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