• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bind NSTableView to array of dictionaries in user defaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bind NSTableView to array of dictionaries in user defaults


  • Subject: Re: Bind NSTableView to array of dictionaries in user defaults
  • From: Keary Suska <email@hidden>
  • Date: Thu, 05 May 2016 14:47:03 -0600

> On May 5, 2016, at 7:44 AM, Jerry Krinock <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Bind NSTableView to array of dictionaries in user defaults
      • From: Jerry Krinock <email@hidden>
References: 
 >Bind NSTableView to array of dictionaries in user defaults (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Very basic need, very difficult to achieve.
  • Next by Date: Re: Very basic need, very difficult to achieve.
  • Previous by thread: Re: Bind NSTableView to array of dictionaries in user defaults
  • Next by thread: Re: Bind NSTableView to array of dictionaries in user defaults
  • Index(es):
    • Date
    • Thread