• 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: forwarding KVO from NSDocument to model
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: forwarding KVO from NSDocument to model


  • Subject: Re: forwarding KVO from NSDocument to model
  • From: Cameron Hayne <email@hidden>
  • Date: Wed, 11 May 2005 11:48:42 -0400


On 11-May-05, at 7:15 AM, Scott Anguish wrote:

if the NSDocument is KVC compliant for those keys, and you're setting them using a KVC compliant means, the NSDocument should work just the same as the existing model object.

On May 11, 2005, at 4:36 AM, Cameron Hayne wrote:

However, it is far from obvious how I should go about setting up the "forwarding" of KVO so that the model changes will get observed. I don't want to have to add an observer for each and every model attribute - but I don't see a nice way to handle it otherwise.


As I said in my original post, the NSDocument doe not have any accessors or instance variables corresponding to the model's instance variables - but it implements valueForUndefinedKey and setValue:forUndefinedKey to forward *all* KVC requests to the model. And this works well - changes in the view do cause changes in the model.


What I was asking about is the other direction - if the model changes, how do I arrange that KVO makes the view change in response? Note again that the model is not bound to the view objects - it is the NSDocument (that has a reference to the model) that is bound to the view objects. And I think there should be a *general* way to have the KVO notifications take effect - without having to do it for each individual model attribute separately.

I have not seen this situation mentioned in any documentation or example. I find this surprising as I would have thought that it was a common situation to have a document-based app where the model is not in the NIB and hence it is necessary to do some "forwarding" of KVO.

--
Cameron Hayne
email@hidden


_______________________________________________ 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: forwarding KVO from NSDocument to model
      • From: Scott Anguish <email@hidden>
References: 
 >forwarding KVO from NSDocument to model (From: Cameron Hayne <email@hidden>)
 >Re: forwarding KVO from NSDocument to model (From: Scott Anguish <email@hidden>)

  • Prev by Date: Re: QTKit: QTMovieView
  • Next by Date: NSTableView autosave columns with CoreData/bindings populated table?
  • Previous by thread: Re: forwarding KVO from NSDocument to model
  • Next by thread: Re: forwarding KVO from NSDocument to model
  • Index(es):
    • Date
    • Thread