• 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: Bindings: is there a better way to observe when an object changes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings: is there a better way to observe when an object changes?


  • Subject: Re: Bindings: is there a better way to observe when an object changes?
  • From: mmalc crawford <email@hidden>
  • Date: Mon, 10 Sep 2007 10:53:23 -0700


On Sep 10, 2007, at 10:34 AM, Simone Tellini wrote:
I've added an "hasChanged" attribute to the entity and made it dependent on all the other keys, using - setKeys:triggerChangeNotificationsForDependentKey:
Then I've bound the view instance to the entity object using the "hasChanged" key path.
I don't like this solution very much, though (for instance, I need to remember to update the hasChanged dependancies if I add/remove an attribute). I tried searching all over the documentation/google for a better way to solve this problem, but I couldn't find anything useful.


Well, ultimately you'll have to propagate changes, so you'll have to remember to update dependencies somewhere... Keeping them encapsulated by a single property means that you only have to remember to update them in one place (rather than, for example, updating the view code each time you update the entity). This is in essence the strategy illustrated in GraphicsBindings (<http://homepage.mac.com/mmalc/CocoaExamples/GraphicsBindings.zip >) although it also makes explicit:

+ (NSSet *)keysForValuesAffectingDrawingBounds;
+ (NSSet *)keysForValuesAffectingDrawingContents;

mmalc

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Bindings: is there a better way to observe when an object changes? (From: Simone Tellini <email@hidden>)

  • Prev by Date: Re: Bindings: is there a better way to observe when an object changes?
  • Next by Date: Re: Bindings: is there a better way to observe when an object changes?
  • Previous by thread: Re: Bindings: is there a better way to observe when an object changes?
  • Next by thread: Re: Bindings: is there a better way to observe when an object changes?
  • Index(es):
    • Date
    • Thread