• 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: self willChangeValueForKey: @"all keys"???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: self willChangeValueForKey: @"all keys"???
      • From: glenn andreas <email@hidden>
References: 
 >self willChangeValueForKey: @"all keys"??? (From: glenn andreas <email@hidden>)
 >Re: self willChangeValueForKey: @"all keys"??? (From: todd ransom <email@hidden>)

  • Prev by Date: Import/Export items
  • Next by Date: Window Grow Button
  • Previous by thread: Re: self willChangeValueForKey: @"all keys"???
  • Next by thread: Re: self willChangeValueForKey: @"all keys"???
  • Index(es):
    • Date
    • Thread