• 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: Is KVO really as complicated as I think?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is KVO really as complicated as I think?


  • Subject: Re: Is KVO really as complicated as I think?
  • From: Óscar Morales Vivó <email@hidden>
  • Date: Tue, 27 Apr 2004 12:31:12 -0400

Basically
setKeys:(NSArray*)theKeys triggerChangeNotificationsForDependentKey:(NSString*)theKey;

Is your best friend. Works as advertised. Use it during initialization (I'm putting those in the +initialize method of the model class). And enjoy.

On 27 Apr 2004, at 12:00, Steve Sims wrote:

OK gang, so I've designed my UI, and have an underlying data model designed too.

It seems to me that all the input elements of my UI can be hooked up to my model fairly easily using bindings. This is very useful to me since I have some dual-control elements where I've got text and sliders referring to the same data.

My data model isn't entirely simple though. I have a number of pieces of data that are derived from other bits of data in my model. It seems to me that by observing changes made to the values within my model that directly affect the derived elements I could potentially automatically regenerate my derived data. Sometimes this would mean that a UI event would change a single variable that would result in a cascade of updates to derived data.

This would seem to be the kind of thing that bindings and KVO are supposed to do. However the documentation is making my head spin right now, and I haven't found any sample code that does anything more complex than really basic bindings stuff - certainly nothing where there's a cascade of changes within a data model.

In my ideal world the way I'd make this work is when I initialize my object I would indicate that a particular selector should be called when one of a particular set of values is changed. Oh, and I'd be able to do this for multiple selectors and related data sets too. Thus I'd be able to set things up so that my desired cascades of changes would happen.

It seems that KVO almost does this, but not quite in the way that I want it to, and right now I'm having trouble bending my brain around the way that KVO does things. It seems that things the KVO way are much more complex, and to get what I want I need an extra layer of abstraction that's not built in.

I've tried searching around for sample code that demonstrates KVO, or articles that better explain the concept, but I'm not coming up with anything right now. Does anyone have any pointers?

Steve
_______________________________________________
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.
_______________________________________________
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.


  • Follow-Ups:
    • Re: Is KVO really as complicated as I think?
      • From: Steve Sims <email@hidden>
References: 
 >Is KVO really as complicated as I think? (From: Steve Sims <email@hidden>)

  • Prev by Date: Re: Grabbing key presses in NSTableView
  • Next by Date: Re: Okay to leave -concludeDragOperation: empty?
  • Previous by thread: Is KVO really as complicated as I think?
  • Next by thread: Re: Is KVO really as complicated as I think?
  • Index(es):
    • Date
    • Thread