Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
- Subject: Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
- From: Uli Zappe <email@hidden>
- Date: Fri, 22 Oct 2004 04:49:14 +0200
Am 22.10.2004 um 04:10 schrieb M. Uli Kusterer:
At 3:50 Uhr +0200 22.10.2004, Uli Zappe wrote:
Well, it doesn't in that NSUserDefaultsController does *not* always
return immutable objects;
However, it is *documented* as returning immutable objects. That's
all the guarantee you get.
OK, maybe you're right and it's a documentation bug, because
NSUserDefaultsController says nothing about changing mutable to
immutable. Note that even if it were documented that NSUserDefaults
returns immutable objects, that *does not* imply that a Binding to
NSUserDefaultsController changes the mutability of the objects in the
bound container. IMHO, a binding should *never* do that, and it is a
real showstopper for this technology because it can lead to all kinds
of problems. So I think you could very well argue that no matter how
NSUserDefaults behave, NSUserDefaultsController should take care to
only return mutable objects to NSArrayController if NSArrayController's
class object is mutable.
Apart from that, wanting to store sets of preferences in an array and
in the user defaults system at the same time is such an obvious
application for Bindings that it should be possible to do this
without all this hassle.
It is. Just treat the array as
As what? Do you want to keep the best part secret? ;-)
If Apple really decides to make immutable the consistent behavior,
then at least they should provide a factory
NSImmutableToMutableTransformer.
There already is. It's called "mutableCopy".
??? I'm not aware that you can enter "mutableCopy" in the Value
Transformer text field of the Bindings Info. That's what I meant - it's
tedious to have to write a custom transformer for this task.
But IMHO you're going about this the wrong way. You should create the
array in your NSArrayController and synchronize it with the prefs, not
modify the prefs directly.
??? But That's exactly what I do. I create the array in
NSArrayController, and as soon as I've done that,
NSUserDefaultsController intervenes and changes my newly created
mutable dictionary to an immutable one without asking me. That's not
nice. ;-)
If you have an intermediate copy, all these problems shouldn't occur.
But they do. That's my point. :-(
And as I said "handles objects as compound value" may help you get
that problem resolved as well.
I'll look into that. Thanks for the hint!
Bye
Uli
________________________________________________________
Uli Zappe, Solmsstraße 5, D-65189 Wiesbaden, Germany
http://www.ritual.org
Fon: +49-700-ULIZAPPE
Fax: +49-700-ZAPPEFAX
________________________________________________________
_______________________________________________
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