Re: NSArrayController <> Shared User Defaults - more detailed

  • On Tue, 1 Jan 2008 13:25:45 +0100, Dominik Pich <dominik...> said:
    > 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?

    This might be all you need:

    http://www.cocoabuilder.com/archive/message/cocoa/2006/4/22/161662

    m.

    --
    matt neuburg, phd = <matt...>, <http://www.tidbits.com/matt/>
    A fool + a tool + an autorelease pool = cool!
    One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
    AppleScript: the Definitive Guide - Second Edition!
    <http://www.amazon.com/gp/product/0596102119>
  • Works yay!
    I dont know why I didn't find this.. it's exactly my issue.

    Thanks a ton :)
    Dominik

    On Jan 1, 2008, at 8:35 PM, Matt Neuburg wrote:

    > On Tue, 1 Jan 2008 13:25:45 +0100, Dominik Pich <dominik...>
    > said:
    >> 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?
    >
    > This might be all you need:
    >
    > http://www.cocoabuilder.com/archive/message/cocoa/2006/4/22/161662
    >
    > m.
    >
    > --
    > matt neuburg, phd = <matt...>, <http://www.tidbits.com/matt/>
    > A fool + a tool + an autorelease pool = cool!
    > One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
    > AppleScript: the Definitive Guide - Second Edition!
    > <http://www.amazon.com/gp/product/0596102119
previous month january 2008 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