Re: NSArrayController array-observation
Re: NSArrayController array-observation
- Subject: Re: NSArrayController array-observation
- From: Scott Anguish <email@hidden>
- Date: Wed, 26 Nov 2003 01:28:23 -0500
On Nov 25, 2003, at 8:01 PM, Dominik Wagner wrote:
On 25.11.2003, at 23:08, Scott Anguish wrote:
On Nov 25, 2003, at 10:00 AM, Dominik Wagner wrote:
On 23.11.2003, at 21:30, Scott Anguish wrote:
On Nov 23, 2003, at 2:05 PM, Dominik Wagner wrote:
Basically it's: How do I observe the contents of an Array?
You can only observe the contents of an array by registering as an
observer on each item in the array. Yes, not the best solution for
you're situation.
Yes, too much overhead for such a simple task.
I'm not sure how.. that's what would happen if the array
automatically supported it.
Yeah, the overhead I mean is that I would have to observe the array
and react on changes to make sure every content dictionary is observed
too. And then of course the handling of the observation callbacks
would be the same as when the array directly supported it.
this isn't that difficult though, since if you implement the indexed
accessor methods for the property with the mutable array there is a
single entrance point.
You could implement a set method for myBool that posts a
notification when the value changes. Not necessarily a good
solution in all cases though.
That would require me to do a model class that is also storeable in
the UserDefaults, the answer here is too much work too.
??? Why would it require this? It shouldn't. Or are you currently
storing these defaults using a dictionary?
Exactly, at the moment I'm storing the Array that contains
Dictionaries with the value for the checkbox and the service type
string.
you could add a category on NSMutableDictionary
Another option might be to make a second accessor with a slightly
different naming scheme (myBoolinIB) that then posted whatever the
change was.
Hmm doesn't sound quite right either.
But this seems to be an important question: what is the right way to
observe non-attribute properties programatically? I mean e.g.
everything stored in the user defaults should somehow be observed by
everything that is concerned, and that includes non UI stuff.
it is. There is an 'interesting' issue if you want to store an
array of values in user defaults (since defaults are not
automatically changed to mutable arrays when they're loaded)
Yes, I encountered this one. Binding the Array directly to the
UserDefaultsController key was my first go, which didn't work because
of this. Now I do a deep copy at the start of the application and set
the userdefaults in the applicationwillterminate method.
another option would be to use the archive and unarchive value
transformers. you may also want to consider writing a two-way deep
mutable transformer.... it could copy the properties to a mutable array
and then write the out afterwards
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.