Re: NSArrayController array-observation
Re: NSArrayController array-observation
- Subject: Re: NSArrayController array-observation
- From: Dominik Wagner <email@hidden>
- Date: Wed, 26 Nov 2003 02:01:12 +0100
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.
>
>> 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.
>
> And somehow I'm thinking that key-value-observing should be the
>
> solution for exactly this: notifying me of changes.
>
I've given you two solutions...
The first one may be the way to go. The second one couples the model to
tight to glue code for my taste.
>
>> 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.
So the solution for attributes stored in the user defaults is binding
to or observing the [[NSUserDefaultsController
sharedUserDefaultsController] values]. "To-One" properties should
always be set if you change the content(?), and same applies to
"to-many" properties because of the interesting issue. Am I correct?
dom
--
Dominik Wagner Mail: email@hidden
TheCodingMonkeys
http://www.codingmonkeys.de/
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.