• 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: Bug in NSArrayController? (immutable instead of mutable dictionaries)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)


  • Subject: Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
  • From: Scott Anguish <email@hidden>
  • Date: Sat, 23 Oct 2004 01:24:54 -0400


On Oct 22, 2004, at 8:03 PM, Uli Zappe wrote:



Am 22.10.2004 um 22:54 schrieb Scott Anguish:

On Oct 22, 2004, at 9:22 AM, Uli Zappe wrote:

2. add a respective example to "Binding Your Preferences in Cocoa", which should also point out that it is crucial for this to work at all that you *must* check the "Handles Content as Compound Value" option in the NSArrayController's Bindings Info - something I never would have guessed from the description of this option in the docs

3. provide a factory value transformer that transforms immutable arrays of immutable objects to mutable arrays of mutable objects (yes, that's not hard to do yourself, but it shouldn't be necessary to do again and again given that this is a standard situation - actually, the very reason that such a transformer does not exist in Cocoa made me believe for quite some hours that this just can't be necessary for my implementation to work since it's such a standard task I'm implementing.)


Yes. However, this isn't anywhere near as straight-forward as it seems.


Well, it didn't seem straight-forward to me ;-) , but now that I got it working I didn't encounter any malfunctioning so far in my tests.

OK, I guess I should say that it has problems of its own. :-)



Nor does it really solve the problem.


Depends on what you think the problem is. You are much deeper into Bindings than I am, but right now, I cannot see what isn't solved the way I do it.

We may very well be talking about two dis-similar situations.

<snip>
Now, where in the above 3 steps do you think a problem remains?

The problem here is likely a somewhat different problem domain.

It's not the controller chaining that is an issue, not at all. The situation I worked on was one where there was an array of data that was stored in defaults. When you added an item, the defaults applied immediately, and there was a complaint of a NULL value. There were other issues as well, in trying to keep the correct items selected when the array had items added to it. Selection was lost.

I was sceptical at the beginning if it is possible at all to bind several controllers together, but Apple's "What Are Cocoa Bindings?" clearly says it is, and I can't see how my implementation differs much from the example in figure 13 of that document.


probably not...



Editing arrays directly from NSUserDefaultsController has all sorts of issues. If you're saving immediately, you have issues with null values getting in there,


I don't understand that, nor have I experienced it in my test (appliesImmediately, which I think you refer to, is YES in my NSUserDefaultsController). Where should null values come from?


if you add a new item to the array (in my cause I was using an array full of dictionary objects) you'd have issues with null items being inserted.


Also, why do you say I edit my array "directly from NSUserDefaultsController"? From my understanding, that's exactly what I don't do. I edit the array in NSArrayController, which *after the change* propagates this change to NSUserDefaultsController via KVC.


Right, but it is the same data. The way I was suggesting actually copied the data as a whole, modified that, and then replaced the original data wholesale.




which means that you have selection issues that come up.


What issues could that possibly be? That after a change in user defaults another dictionary in NSArrayController's content array is selected than before? I couldn't test that thoroughly so far.

in my case I had issues that selection would change or be lost when the entire array was written back to the user defaults (and then the results updated)


The NSUserDefaultsController doesn't know that the NSArrayController that it is sending data back to (via KVO) expects mutability. There isn't a mechanism for that, KVO is a one way message. So, while it's true that it appears that it is two way, they are in fact to entirely separate processes. KVC to set, KVO returns the new value.


Yep, I know, but I still think it's a shame this can't be handled more intelligently.

Honestly, I'm surprised to see how complicated Bindings can become as soon as you have something a bit more advanced in its structure. As I said before, I think handling user preferences are a prime example for the usefulness of Bindings, and still, if they become a little bit more advanced than the very basic case that is dealt with in "Binding Your Preferences in Cocoa", it becomes so problematic immediately. Which is why I think that "Binding Your Preferences in Cocoa" really should be enhanced by additional examples and canonic implementations for cases like the one above.


No argument there... and I've got a list of things to cover.... if you have specific requests, please, please file bugs. then I get to work on them.. :-)



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
      • From: Uli Zappe <email@hidden>
References: 
 >Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Brent Gulanowski <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: "M. Uli Kusterer" <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: "M. Uli Kusterer" <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Scott Anguish <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Scott Anguish <email@hidden>)
 >Re: Bug in NSArrayController? (immutable instead of mutable dictionaries) (From: Uli Zappe <email@hidden>)

  • Prev by Date: Global User Agent?
  • Next by Date: Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
  • Previous by thread: Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
  • Next by thread: Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
  • Index(es):
    • Date
    • Thread