Re: self willChangeValueForKey: @"all keys"???
Re: self willChangeValueForKey: @"all keys"???
- Subject: Re: self willChangeValueForKey: @"all keys"???
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 25 Mar 2005 15:53:57 -0800
On Mar 25, 2005, at 10:26 AM, glenn andreas wrote:
So I've got a class (an ephemeris that calculates all sort of
information about sun/moon/planets/etc...) that has a whole bunch
of derived values (as in dozens, and probably many more than that
later) that change when a single "master" value changes, [...]
As I see it, I can either write a boat load of [self setKeys:
[NSArray arrayWithObject: @"master"]
triggersChangeNotificationsForDependantKey: @"key1"] during my
initialize method, or else do a similar thing in when the master
value is set with
"willChangeValueForKey:"/"didChangeValueForKey:". Either way, I
need to be constantly updating this to make it longer and longer
(and when I'm done I could possible have keys in the hundred+ range).
To make things worse, if there are additional categories added with
more derived information (so I can add on methods for different
sort of astronomical information), so though I separate the object
into nice distinct categories of functionality, I constantly have
to update the base implementation (which is certainly error prone).
Is there any sort of magic "everything has changed" key?
No, there isn't an "everything changed" key.
I can certainly appreciate that it may be considered tedious or error
prone to have to specify the
triggersChangeNotificationsForDependantKey: dependencies, however:
As you're toiling though it, you should bear in mind the amount of
other code you're *not* writing. Consider what you would have to do
to ensure a consistent user interface etc. if you were not using KVO.
If it helps to justify the intellectual endeavour, consider the
implementation as business logic. It is code that is essential to
write to properly specify the behaviour of your model objects...
On Mar 25, 2005, at 12:27 PM, todd ransom wrote:
I recently added a mutableKeys method to my base model class and I
think something similar could help you here.
I'm not sure this will be directly relevant to the case of dependent
keys, unless you implement a suite of methods along the lines of:
-(NSArray *)keysOnWhichBlahDepends
{
return [NSArray ...];
}
mmalc
_______________________________________________
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