Bindings: NSArrayController <> Shared User Defaults

  • Hi,
    as the title states I have a Problem with binding my ArrayController
    to the Shared User Defaults... changes to items in the array dont get
    flushed back

    I have an array in a plist in my bundle:
    <items>
    <dict>
      <key>name</key>
      <string>bla1</string>
      <key>enabled</key>
      <true/>
    </dict>
    <dict>
      <key>name</key>
      <string>bla22222</string>
      <key>enabled</key>
      <true/>
    </dict>
    <dict>
      <key>name</key>
      <string>bla33</string>
      <key>enabled</key>
      <true/>
    </dict>
    </items>

    this array I read from plist, I use with registerDefaults as a key:
    "items"

    I then bind an NSArrayController to the shared defaults controller
    using values.items as the binding. To that Controller I bind a
    tableView. 1. Column :: name, 2. Column: enabled (using a
    PopupButtonCell)

    I CANNOT add or remove items from the array -- dont want
    I want to be able to toggle the enabled state of items

    --- all working great so far ^^

    But now comes the Problem: Changes are never ..... committed back to
    the defaults.
    Why is that? It seems to me that the new array is somehow considered
    to be identical to the old?

    Regards,
    Dominik
  • On 2007 Dec, 31, at 2:42, Dominik Pich wrote:

    > To that Controller I bind a tableView.

    I made that mistake my first time.  Binding to an NSTableView doesn't
    work.  Instead, bind each NSTableColumn to the array controller with
    Controller Key = 'arrangedObjects', and Model Key Path = 'name' for
    the first column and Model Key Path = 'enabled' for the second column.

    After that, your message is difficult to understand, so if you're
    still having trouble, I'd suggest you restate it.
  • Hi,
    as the title states I have a Problem with binding my ArrayController
    to the Shared User Defaults...

    I have for example this array:
    <items>
    <dict>
      <key>name</key>
      <string>bla1</string>
      <key>enabled</key>
      <true/>
    </dict>
    <dict>
      <key>name</key>
      <string>bla22222</string>
      <key>enabled</key>
      <true/>
    </dict>
    <dict>
      <key>name</key>
      <string>bla33</string>
      <key>enabled</key>
      <true/>
    </dict>
    </items>

    --- Here's what I do:
    -the above array I read from plist
    - I use it as initial value for the NSUserDefault as a key: "items"

    - I then bind an NSArrayController to the shared defaults controller
    using contentArray=values.items as the binding.
    -To that Controller I bind the columns of a tableView.
    using value=arrangedObjects.name as the Binding for the 1. Column
    using value=arrangedObjects.enabled as the Binding for the 2. Column
    (using a PopupButtonCell)

    --- all working great so far ^^
    -> I can SEE the array I bound to just fine

    ---But now comes the Problem:
    -> I want to be able to modify my array ... I dont want to add or
    remove objects BUT modify individual items' values. Especially I want
    to toggle their enabled states.

    The changes I make in my tableView though (via the popupButtons) are
    not 'reqistered' by the defaults. I never get a notification something
    changed, nor does the defaults save the modified array.

    Why is that? It seems to me that the new array is somehow considered
    to be identical to the old?

    Regards,
    Dominik
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today